Iwas able to upgrade from Drupal 4.7 to 5.3, however i found a problem using the [acidfree] tag. There is no problem if i provide a size, but if i use size=M then i get the following error:

warning: Division by zero in /var/www/drupal/sites/all/modules/acidfree/acidfree.module on line 1876.

I can see the images always (albums preview, thumbnail) except when i use size=M to add images to a story or page.

Any ideas?

Comments

Obi-Wan@hispa-net.com’s picture

Category: bug » support

The problem that causes division by zero is

            if ($aspect < $height / $width) {
                $width = (int)min($width, $f_width);
                $height = (int)round($width * $aspect);
            }
            else {
                $height = (int)min($height, $f_height);
                $width = (int)round($height / $aspect);
            }

acidfree.module, line 1876

But in fact the problem is this code:

$size = explode('x', $settings['size']);
$width = $size[0]; $height = ($size[1] ? $size[1] : $size[0]);

acidfree.module, line 1866

because $size[0] and $size[1] returns 'M' as value instead a number.

vhmauery’s picture

Status: Active » Closed (works as designed)

M is not one of the options. Specify the size in pixels.

Obi-Wan@hispa-net.com’s picture

From Acidfree help:

* size: {M, WxH} where M=max dimension and WxH=WidthxHeight

Obi-Wan@hispa-net.com’s picture

Status: Closed (works as designed) » Active
vhmauery’s picture

Status: Active » Closed (works as designed)

M is a placeholder for a number (in pixels) of the Max Dimension. Whereas WxH is the same thing but that allows you to specify the height and width manually (and possibly in a ratio that does not match the image proportions. Sorry if the documentation is confusing, but it behaves exactly as I intended it. If you don't like that, please submit a patch to the documentation.

Obi-Wan@hispa-net.com’s picture

On your 4.x releases size=M showed the image using original dimensions. But after upgrade to 5.x stopped working.

Should I change ALL the acidfree tags by hand to show the images at full dimensions again? :-(

vhmauery’s picture

Hmmm. That sounds like 4.7 was broken. Poor user input filtering...

Something that might help would be an sql query to update your nodes for you.

mysql> UPDATE node_revisions SET body=REPLACE(body,'size=M', 'size=640');

Now, be very careful with that. Please back up your database first. That will set all your inlines to be 640 pixels in one dimension (and the other will keep the aspect ratio of the image).

vhmauery’s picture

I suppose a more specific query might be a better idea...

mysql> UPDATE node_revisions SET body=REPLACE(body,'size=M', 'size=640') WHERE body like '%[acidfree:%size=m%]%';

This only messes with nodes that actually have [acidfree:nnn] tags