Welcome, Guest
Username Password: Remember me

Image scaling Bug + suggested fix ...
(1 viewing) (1) Guest
  • Page:
  • 1

TOPIC: Image scaling Bug + suggested fix ...

Image scaling Bug + suggested fix ... 13 years, 2 months ago #5424

  • cehlscheid
  • OFFLINE
  • Fresh Boarder
  • Posts: 1
  • Karma: 0
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!
Last Edit: 13 years, 2 months ago by cehlscheid.

Re: Image scaling Bug + suggested fix ... 13 years, 2 months ago #5425

  • dryabov
  • OFFLINE
  • Administrator
  • Denis Ryabov, Lead Developer
  • Posts: 4867
  • Karma: 105

Re: Image scaling Bug + suggested fix ... 13 years, 1 month ago #5671

  • kandles
  • OFFLINE
  • Fresh Boarder
  • Posts: 5
  • Karma: 0
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.

Re: Image scaling Bug + suggested fix ... 13 years, 1 month ago #5682

  • dryabov
  • OFFLINE
  • Administrator
  • Denis Ryabov, Lead Developer
  • Posts: 4867
  • Karma: 105
kandles, what is URL of your site?

Re: Image scaling Bug + suggested fix ... 13 years, 1 month ago #5717

  • kandles
  • OFFLINE
  • Fresh Boarder
  • Posts: 5
  • Karma: 0
Sorry for delay in reply - been working on other things. Website is www.apres-sail.com.

Re: Image scaling Bug + suggested fix ... 13 years, 1 month ago #5718

  • dryabov
  • OFFLINE
  • Administrator
  • Denis Ryabov, Lead Developer
  • Posts: 4867
  • Karma: 105
Seems rescaling works well. What exact issue do you have?

Re: Image scaling Bug + suggested fix ... 13 years, 1 month ago #5738

  • kandles
  • OFFLINE
  • Fresh Boarder
  • Posts: 5
  • Karma: 0
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!
  • Page:
  • 1
Time to create page: 0.10 seconds

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.