Welcome, Guest
Username Password: Remember me

Image resize doubling slashes
(1 viewing) (1) Guest
  • Page:
  • 1

TOPIC: Image resize doubling slashes

Image resize doubling slashes 13 years, 8 months ago #455

  • drewgg
  • OFFLINE
  • Fresh Boarder
  • Posts: 10
  • Karma: 0
Joomla version: 1.5.20
Mobile Joomla! version: 0.9.7
PHP version: 5.2.8

A number of images were broken on the mobile version of the site I was testing. I narrowed it down to images that are being resized. The URL after resize always started off with slashes (//) instead of one:

<img [snip] src="//images/stories/Resized/imagename_240x253.jpg" />

It happens regardless of whether the original image URL is relative or absolute. The culprit is in /administrator/components/com_mobilejoomla/imagerescaler.class.php line ~180:

 
$dest_imageuri = $base_rel.implode('/', explode(DS, substr($dest_imagepath, strlen(JPATH_SITE))));
 


If the image's path ($dest_imagepath) is:

/home/sitepath/public_html/images/stories/Resized/imagename_240x253.jpg

Then the substr() will shorten it to

/images/stories/Resized/imagename_240x253.jpg

The explode() will result in an array like this:

 
Array (
[0] =>
[1] => images
[2] => stories
[3] => Resized
[4] => imagename_240x253.jpg
)
 


And finally the implode() will result in this:

//images/stories/Resized/imagename_240x253.jpg

Which is what is returned as the URI path ($dest_imageuri).

Is this a known issue? I would think something like this would have been picked up and fixed a during initial testing, considering it breaks all resized images...

Either way, my solution was to simply check for double slashes and remove one them if found:

 
$dest_imageuri = $base_rel.implode('/', explode(DS, substr($dest_imagepath, strlen(JPATH_SITE))));
$dest_imageuri = str_replace("//", "/", $dest_imageuri);
 

Image resize doubling slashes 13 years, 8 months ago #2092

  • dryabov
  • OFFLINE
  • Administrator
  • Denis Ryabov, Lead Developer
  • Posts: 4866
  • Karma: 105
drewgg, thanks for report. Will be fixed in 0.9.8 soon.

Image resize doubling slashes 13 years, 8 months ago #2094

  • drewgg
  • OFFLINE
  • Fresh Boarder
  • Posts: 10
  • Karma: 0
coolies. Thanks!

Image resize doubling slashes 13 years, 8 months ago #2101

  • drewgg
  • OFFLINE
  • Fresh Boarder
  • Posts: 10
  • Karma: 0
Just to let you know, I changed my patch to simply add 1 to the strlen(JPATH_SITE):

 
$dest_imageuri = $base_rel.implode('/', explode(DS, substr($dest_imagepath, strlen(JPATH_SITE)+1)));
 

Image resize doubling slashes 13 years, 8 months ago #2102

  • dryabov
  • OFFLINE
  • Administrator
  • Denis Ryabov, Lead Developer
  • Posts: 4866
  • Karma: 105
In SVN we changed it to
$dest_imageuri = $base_rel.implode('/', explode(DS, substr($dest_imagepath, strlen(JPATH_SITE.DS)))); 

(it seems more clear)

Image resize doubling slashes 13 years, 8 months ago #2112

  • drewgg
  • OFFLINE
  • Fresh Boarder
  • Posts: 10
  • Karma: 0
I agree

Image resize doubling slashes 13 years, 8 months ago #2129

Thanks for the code fix. I had the issues and your fix worked great!

Just installed this on my site and love it!

Looking forward to more

Dan

Image resize doubling slashes 13 years, 8 months ago #2146

  • Gam3sfa
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
  • Karma: 0
Someone I can pass the file already done? because the images are not seen.
  • Page:
  • 1
Time to create page: 0.30 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.