imagecache icon indicating copy to clipboard operation
imagecache copied to clipboard

Custom templates doesn't work

Open avxkim opened this issue 9 years ago • 2 comments

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.

avxkim avatar Jun 27 '15 09:06 avxkim

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.

urbankid avatar Aug 03 '15 10:08 urbankid

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.

zachleigh avatar Sep 26 '16 05:09 zachleigh