Image scaling Bug + suggested fix ...

cehlscheid
13 years, 7 months ago
Hello,

there's a little bug in the ImageScaler class,

In the function "imageParsing" the height and width of the image is retrieved.
If the image has a style tag like: style="border-width: 1px ..." the image is resized to 1px width.

The regular expression to extract the "width" out of the style tag needs to be fixed.
Since all images in Joomla typically are sized with the "width" and "height" attributes of the img tag, i've fixed it by moving the code which reads the width and height out of the attributes behind the code wihch reads the values out of the style.

...
// styles
if(preg_match('#\Wwidth\s*:\s*(\d+)\s*(px|!|#i', $text, $matches)) // needs fix
   ImageRescaler::$forced_width = intval($matches[1]);
if(preg_match('#\Wheight\s*:\s*(\d+)\s*(px|!|#i', $text, $matches)) // probably needs fix too   ImageRescaler::$forced_height = intval($matches[1]);

// img attribules  - moved this code after the above ...
if(preg_match('#\swidth\s*=\s*([\'"]?)(\d+)\1#i', $text, $matches))
   ImageRescaler::$forced_width = intval($matches[2]);
if(preg_match('#\sheight\s*=\s*([\'"]?)(\d+)\1#i', $text, $matches))
   ImageRescaler::$forced_height = intval($matches[2]);

VERY NICE COMPONENT!! Keep up the good work!
kandles
13 years, 7 months ago
I have tried both the fixes above and still can not get the images to appear.
If I turn the Image adaptation method to "Don't rescale" then the images appear. Using RC3 on a smartphone.
dryabov
13 years, 7 months ago
kandles, what is URL of your site?
kandles
13 years, 7 months ago
Sorry for delay in reply - been working on other things. Website is www.apres-sail.com.
dryabov
13 years, 7 months ago
Seems rescaling works well. What exact issue do you have?
kandles
13 years, 7 months ago
That is interesting that it seems to work with you. Found the problem - me not reading the instructions I expect! The pics which are not appearing were gifs - converted them to jpgs and it works. Sorry!

By continuing to use this site you consent to the use of cookies on your device as described in our cookie policy unless you have disabled them. This site will not function correctly without cookies.

I accept cookies from this site.