Small code implementation for image rescaling

customhost
14 years, 3 months ago
Hi guys,

I kindly ask you to implement the following piece of code in the next release of MobileJoomla.

Before lines 181-182 in imagerescaler.class.php:
if(file_exists($dest_imagepath))
return $dest_imageuri;


Please add the following:
if(substr($dest_imageuri,0,2) == '//')
$dest_imageuri = substr($dest_imageuri,1);


The sense behind this check is that on an IIS webserver, if an image source starts with 2 double slashes (e.g. "//images/stories/Resized/image.gif" instead of "/images/stories/Resized/image.gif"), the rescaled image is not displayed. The above code takes care of this issue and reforms the URL if necessary.

Cheers,
Eric
miohtama
14 years, 2 months ago
OK - we'll merge this with trunk.

Ps. Source code is now at Github so we can accept contributions through that way also. See the recent blog post.
jerms
14 years ago
Hello,

is it possible to make this instruction compatible with PHP5.1 :
$src_imagename = pathinfo($imageurl, PATHINFO_FILENAME);


I needed to create a function to verifiy if the constant "PATHINFO_FILENAME" is defined, because my provider only has PHP5.1, and this was implemented in 5.2
  function pathinfo_filename($file)  {
if (defined('PATHINFO_FILENAME')) return pathinfo($file,PATHINFO_FILENAME);
if (strstr($file, '.')) return substr($file,0,strrpos($file,'.'));
}
 


$src_imagename = ImageRescaler::pathinfo_filename($imageurl);


thanks,
Jerm's
dryabov
14 years ago
jerms, thanks a lot!

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.