php-image-cache icon indicating copy to clipboard operation
php-image-cache copied to clipboard

Cannot Output the Compressed image on WAMP server

Open ghost opened this issue 10 years ago • 2 comments

I am having trouble displaying the compressed Image on my local server(WAMP). The image compression works perfectly, but when I try to echo out the image in tag, it displays a broken image.

Heres my folder structure:

sample (root folder) -images (inside sample) -cached (inside images, here's where the cached file goes) -f3ccdd27d2000e3f9255a7e3e2c48800.jpg(cached image) -1.jpg (Image to be compressed, inside images folder) -ImageCache.php (inside sample) -index.php (inside sample)

Thanks!

ghost avatar Jan 05 '15 16:01 ghost

Same issue. $imagecache->cached_image_directory = 'images/cached'; URL: //os.dev/php-image-cache-master/demo/mages/cached/46c4075edc3b25e6e54c45635704c838.jpeg

It is all right, minus /mages/ which should be /images/. Why is the 'i' being removed?

And see nothing in the class that would do that! Grr.

Wait, I see it. "$image_url = $url . substr($image_path, 1);"

In function docroot_to_url.

neotropic2023 avatar Apr 28 '15 17:04 neotropic2023

I made some changes here. I added one more variable to be passed which is the URL.

$imagecache = new ImageCache(); $imagecache->cached_image_path = PATH TO\php-image-cache-master\demo\images\cached'; $imagecache->cached_image_url = 'URL TO/php-image-cache-master/demo/images/cached/';

On the class file, right below: public $cached_image_directory; ADDED public $cached_image_url;

Then changed function docroot_to_url to: private function docroot_to_url($src = null) { if( is_null( $src ) ) { $src = $this->cached_filename; } $image_path = str_replace($this->cached_image_directory, '', $src); $image_url = $this->cached_image_url . $image_path; if($this->link_is_broken($image_url)) { $this->error('Final image URL is broken'); } return $image_url; }

I just kept seeing paths appearing and for my structure setup I needed it to be this way.

neotropic2023 avatar Apr 28 '15 18:04 neotropic2023