Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot Output the Compressed image on WAMP server #14

Open
ghost opened this issue Jan 5, 2015 · 2 comments
Open

Cannot Output the Compressed image on WAMP server #14

ghost opened this issue Jan 5, 2015 · 2 comments
Assignees

Comments

@ghost
Copy link

ghost commented Jan 5, 2015

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!

@nielse63 nielse63 self-assigned this Jan 25, 2015
@neotropic2023
Copy link

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
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants