Modification thumbnail type for block

Permalink
Hello,

I would like to change the thumbnail type in the attribute page block.
Someone would have an idea of ​​how should I go about it?

Thank you very much

View Replies:
mnakalay replied on at Permalink Reply
mnakalay
You can change the thumbnail dimensions if you want.

In your template, before this piece of code
$controller->getContent()

you can write this
$controller->thumbnailWidth = 450;
$controller->thumbnailHeight = 450;

Modify 450 for any value you want. You also don't have to use both values, you can use one and the other will fallback to its default value of 250.

By default, the resizing is proportional and doesn't crop the image. There is no simple way to change that. There is a way, it's just not simple.
Zeranza replied on at Permalink Reply
Thank you for this quick response.
Resize the image, I had an idea to do it but actually it was not that one, so it'll be able to help me.

On the other hand, I saw on the help :

https://documentation.concrete5.org/developers/working-with-files-an...

I can not find in the attribute page block, where I have to put it.
mnakalay replied on at Permalink Reply
mnakalay
the attribute page block is in concrete/blocks/page_attribute_display
But you should not modify it directly or you will lose your modifications next time you update Concrete5
Zeranza replied on at Permalink Reply
But is not it possible to create a template on this block? to be able to use :

$type = \Concrete\Core\File\Image\Thumbnail\Type\Type::getByHandle('gallery');
foreach($images as $file) {
if (is_object($file)) {
$src = $file->getThumbnailURL($type->getBaseVersion());
echo '<div class="thumbnail">';
echo "<img src=\"$src\" alt=\"{$file->getTitle()}\" width=\"{$type->getWidth()}\" height=\"{$type->getHeight()}\">";
echo '</div>';
}
}

?
mnakalay replied on at Permalink Reply
mnakalay
in the view, instead of
echo $controller->getContent();

use
$c = Page::getCurrentPage();
$content = $c->getAttribute($controller->attributeHandle);
if (is_object($content) && ($content instanceof Concrete\Core\Entity\File\File || $content instanceof \Concrete\Core\Entity\File\File)) {
    $type = \Concrete\Core\File\Image\Thumbnail\Type\Type::getByHandle('gallery');
    $src = $content->getThumbnailURL($type->getBaseVersion());
    echo "<img src=\"{$src}\" width=\"{$type->getWidth()}\" height=\"{$type->getHeight()}\" alt=\"\" />";
} else {
    echo $controller->getContent();
}
Zeranza replied on at Permalink Reply
Thank you very much is perfect.

Do you have an idea to do the same thing on the block slider image?

Thank you again for your response as fast and efficient.