Getting thumbnails

Media Module


Media Module: Getting a thumbnail

If you want to get a specific thumbnail of an image you can have 2 choices. Either you're in a view, then you'll use the Facade, if not use class/method injection.

Injection

/**
 * @var Imagy
 */
private $imagy;

public function __construct(Imagy $imagy)
{
    $this->imagy = $imagy;
}

public function index()
{
    $thumbnail = $this->imagy->getThumbnail('/assets/media/original-image-name.png', 'smallThumb');
}

Facade

In views, you can use the facade for ease of use. Simply send as first argument which image you want and which thumbnail:

<img src="{{ Imagy::getThumbnail('/assets/media/original-image-name.png', 'smallThumb') }}" alt="" />

Mobile Analytics