Technical notes about OctoberCMS a Laravel CMS. Notes are written by inetis team, a Swiss webagency

<- Back

Generate Thumbnails

Posted on by

OctoberCMS provide a great way to manage thumbnails.

The easiest way to generate ‘on the fly’ thumbnails is to use System\Models\File model in relation like :

public $attachMany = [
    'myimages' => ['System\Models\File']

Show a thumbnail

To access those images in your layout or partial, you can use the following code. We are using the .thumb(x,y, mode) function to generate the thumbnail.

{% for image in myobject.myimages %}
    <img src="{{ image.thumb(200, 200, 'auto') }}" title="{{ image.title }}" alt="{{ image.description }}">
{% endfor %}

You can set the mode to auto, exact, portrait, landscape or crop. Default: auto

Delete all thumbnails files

You can use the following command to delete all the thumbnails cache file

php artisan october:util purge thumbs