responsive images

Permalink Browser Info Environment
Is it possible to use the responsive images?
I like the feature of using an generated thumbnail, but it behaves different.

Type: Pre-Sale
Status: Archived
designbureau
View Replies:
Parasek replied on at Permalink Reply
Parasek
Hi

what do you mean by using responsive images? You can make images responsive just by few line of css (and anyway it's usually implemented in most themes).

Or do you mean using concrete5 thumbnails system (/dashboard/system/files/thumbnails) ?
designbureau replied on at Permalink Reply
designbureau
I guess thats what we want.
We have in our theme (proprietory "Elemental-Theme") an extendable image thumbnailing system, creating multiple thumbnails like "small" 740px, "medium" 940px and "large" 1140px.
How can we make use this with your rather fantastic block?
Parasek replied on at Permalink Reply
Parasek
If you want to display images similar to "Content" block, you need to:
(replace "yourHandle" and "yourHandleRep" with handle that you are using)

1. Image field in "Basic Information" tab

Create block with image field:
Label: "Example image"
Handle: "yourHandle"

In view.php paste:
<?php if (!empty($yourHandle_link)): ?>
    <?php
    // Picture tag
    $yourHandle_tag = \Concrete\Core\Support\Facade\Application::getFacadeApplication()->make('html/image', [$yourHandle_object])->getTag();
    $yourHandle_tag->alt(h($yourHandle_alt));
    echo $yourHandle_tag;
    ?>
<?php endif; ?>


2. Image field in "Entries" tab

Create block with repeatable image field:
Label: "Example image"
Handle: "yourHandleRep"

In generated controller.php find prepareForViewImage() method and remove double slash from line below:
// $entry[$fileIDFieldName.'_object']   = $fileObject


In view.php paste:
<?php if (!empty($entry['yourHandleRep_link'])): ?>
   <?php
   // Picture tag
   $entry['yourHandleRep_tag'] = \Concrete\Core\Support\Facade\Application::getFacadeApplication()->make('html/image', [$entry['yourHandleRep_object']])->getTag();
   $entry['yourHandleRep_tag']->alt(h($entry['yourHandleRep_alt']));
   echo $entry['yourHandleRep_tag'];
   ?>
<?php endif; ?>



3. Also if you want to get url of specific thumbnail, you can do something like that:
echo $yourHandle_object->getThumbnailURL('small');
echo $yourHandle_object->getThumbnailURL('small_2x');
echo $entry['yourHandleRep_object']->getThumbnailURL('medium');
echo $entry['yourHandleRep_object']->getThumbnailURL('medium_2x');

Unfortunately to get width and height of those thumbnails, you need to manually check if it exists and use getimagesize() function.
designbureau replied on at Permalink Reply
designbureau
Thank you so much about your extensive information.

Unfortunately I do not understand enough to modify PHP-files. I thought it was easy, but I understand that this a complicated yet powerful tool.

Our block pulls an original 800px image in an isotope grid. The small images should be used in the large viewport and a large image is pulled for xs screens – sort of opposite use than normal.

I have to get in touch with the developer of our block, - maybe they can take care of it and use your codes shown above.

We also have to get going, to populate our site which is due next week. I hope we can add a possible solution later, exchanging the view file.

"Thumbs" up for your work.

stef

concrete5 Environment Information

concrete5 8.4

Browser User-Agent String

Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:70.0) Gecko/20100101 Firefox/70.0

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You have not specified a license for this support ticket. You must have a valid license assigned to a support ticket to request a refund.