Intervention / imagecache

Caching extension for the Intervention Image Class
https://image.intervention.io/v2/usage/cache
MIT License
636 stars 115 forks source link

Custom templates doesn't work #49

Open avxkim opened 9 years ago

avxkim commented 9 years ago

Contents of "app/config/packages/intervention/imagecache/config.php":

    'templates' => array(
        'small' => 'Intervention\Image\Templates\Small',
        'medium' => 'Intervention\Image\Templates\Medium',
        'large' => 'Intervention\Image\Templates\Large',
        'test' => 'App\Filters\Test'
    ),

Placed file with my custom preset under "app/filters/filters.php":

namespace App\Filters;

use Intervention\Image\Image;
use Intervention\Image\Filters\FilterInterface;

class Test implements FilterInterface
{
    public function applyFilter(Image $image)
    {
        return $image->fit(30, 30);
    }
}

But it doesn't work. If i use in my url "imagecache/test/image.jpg" it displays in original size, seems like laravel not seeing this namespace.

urbankid commented 9 years ago

Hi @heihachi88 I had the same problem and was able to solve it by adding:

{
  "autoload": {
    "classmap": [
      "app/filters"
    ]
  }
}

to my composer.json and then doing:

composer dump-autoload 

from my terminal.

I wasted lots of time trying to figure out what the problem was and would really appreciate if they had some guidelines to the documentation.

But besides that I really love this project and want to thank everyone for their good work.

zachleigh commented 7 years ago

Having the same type of problem.

    'templates' => array(
        'small' => 'Elephany\Http\ImageFilters\Small',
        'medium' => 'Elephany\Http\ImageFilters\Medium',
        'large' => 'Elephany\Http\ImageFilters\Large',
        'smallbanner' => 'Elephany\Http\ImageFilters\SmallBanner'
    ),

SmallBanner is doing nothing. For testing, I set it the same as Small:

class Small implements FilterInterface
{
    public function applyFilter(Image $image)
    {
        return $image->fit(40, 40);
    }
}
class SmallBanner implements FilterInterface
{
    public function applyFilter(Image $image)
    {
        return $image->fit(40, 40);
    }
}

Small is working correctly, but SmallBanner just returns the original image even though the class is the exact same.

Got it to work. Not sure if it was me not clearing the cache or a class naming issue, but its working now.