"Fossies" - the Fresh Open Source Software Archive

Member "forkcms/docs/05. module guide/11. generate_thumbnails_based_on_folder.md" (5 Dec 2019, 1348 Bytes) of package /linux/www/forkcms-5.7.1.tar.gz:

As a special service "Fossies" has tried to format the requested source page into HTML format (assuming markdown format). Alternatively you can here view or download the uninterpreted source code file. A member file download can also be achieved by clicking within a package contents listing on the according byte size field.

Generate thumbnails based on folder

In the 3.3.12 release we introduced a way to generate thumbnails based on the folders in a given path.

For instance if you have a module that allows the administrator to upload an image, you probably want to create a thumbnail to show it in the datagrid. But on the frontend you will need the image in differents sizes, for instance a square 128x128-image to use in the overview, or a image where the maximum width is 720px.

Well from now on you don’t have to worry about writing that code. Just create the folders:

In your module you can use the code below:

$this->form->getField('image')->generateThumbnails($imagePath, time() . '.png');

Where $imagePath is the folder that contains the thumbnail folders, if it doesn’t exists a folder called source will be created to store the source-file.

Generating thumbnails using the CLI

bin/console forkcms:thumbnails:generate --folder=Users/avatars