Created
July 20, 2017 15:21
-
-
Save Kaapiii/d8edfad2e8b759b115f883a05503c6ed to your computer and use it in GitHub Desktop.
Concrete5 - Add thumbnail types programmatically
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Tested with Concrete5 version 8.2.0 | |
$type = \Concrete\Core\File\Image\Thumbnail\Type\Type::getByHandle('custom_100x100px'); | |
if(!is_object($type)){ | |
$typeEntity = new \Concrete\Core\Entity\File\Image\Thumbnail\Type\Type(); | |
$width = 100; // px | |
$height = 100; // px || null for auto | |
if ($height > 0) { | |
$typeEntity->setHeight($height); | |
} | |
if ($width > 0) { | |
$typeEntity->setWidth($width); | |
} | |
$typeEntity->setName('Thumb 100 x 100 px'); | |
$typeEntity->setHandle('custom_100x100px'); | |
$typeEntity->setSizingMode('proportional'); // values: proportional, exact | |
$typeEntity->save(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment