kevbaldwyn / image

Responsive images and on the fly image sizing for laravel 4 and fuel php
23 stars 13 forks source link

Responsive is not working correctly or perhaps not documented correctly #3

Closed ghost closed 10 years ago

ghost commented 11 years ago

Trying to use the ->responsive method and getting a 404 on the image returned. When the ->responsive method is removed, the image works great. Otherwise, the package is great. Keep up the good work! I am using Laravel v4.

kevbaldwyn commented 11 years ago

Thank you! Can you post here how you are implementing the responsive method? Maybe the documentation is not correct, or maybe there is a bug, both are possible!!

vladoa commented 11 years ago

I can't get this to work at all - I am getting 404 not found on the image returned with something like:

http://localhost/_img?img=/public/images/image.jpg&transform=resizeCrop,400,200

My url config in app.php is: 'http://localhost/laravel' The image is set in 'public/images/image.jpg' The imagecow.js is in public/js/imagecow.js

I am including the js like this:

<script type="text/javascript" src="<?php echo Config::get('app.url'); ?>/public/js/Imagecow.js"></script>

and the image like this:

 <img src="{{ Image::path('/public/images/image.jpg', 'resizeCrop', 400, 200) }}" />

and here is my image config:

<?php

return array(

    /**
     * the image worker (GD / Immagick)
     */
    'worker' => 'GD',

    'route' => '/_img',

    /**
     * note this is the server path to the file 
     * from base_path()
     */
    'js_path' => 'public\js\Imagecow.js',

    /**
     * various $_GET variables
     */
    'vars' => array(
        'image'           => 'img',
        'responsive_flag' => 'responsive',
        'transform'       => 'transform'
    ),

    'cache' => array(
        'lifetime' => 1,
        'path'     => 'images' // /app/storage/cache/{images}
    )

);

Could you please advise how to get it to work or what am I missing?

kevbaldwyn commented 11 years ago

The package assumes images are in the public directory so prepends the public path to them so you don't need to. You should call your image path as you would any image being rendered in your application as normal (ie without the /public prefix). So your example should be:

<img src="{{ Image::path('/images/image.jpg', 'resizeCrop', 400, 200) }}" />

The same should be for the javascript lib. The package actually includes a method to write the correct script tag (although it's not documented:

{{ Image::js() }}

Just add that in your <head>