Create thumbnails type in custom block type

Permalink
Hello! Please help me.
How to create custom thumbnail type in custom block type? Maybe in controller.php file. How to do it?
Thanks.

 
MrKDilkington replied on at Permalink Reply
MrKDilkington
Hi antonovsky,

Here is an example that you can try. The code will most likely be used in a controller.
// important the Type class
use Concrete\Core\File\Image\Thumbnail\Type\Type;

// check to see if the thumbnail type object exists before creating it
// - get the thumbnail type by handle "my_thumbnail"
$thumbnailType = Type::getByHandle('my_thumbnail');
// check to see if the the thumbnail type is an object or not
// - if it isn't an object, create a new thumbnail type "my_thumbnail"
if (!is_object($thumbnailType)) {
$type = new Type();
$type->setName('My Thumbnail');
$type->setHandle('my_thumbnail');
$type->setWidth(100);
// optional
//$type->setHeight(100);
// requireType() will create thumbnail types that cannot be deleted through the concrete5 interface
// $type->requireType();
$type->save();

http://documentation.concrete5.org/api/class-Concrete.Core.File.Ima...
antonovsky replied on at Permalink Reply
This code should be placed in on_start() function?
MrKDilkington replied on at Permalink Reply
MrKDilkington
@antonovsky

Where you place it depends on the rest of your code and how you intend to use it.