I’m trying to get the a thumbnail working with a custom attribute. But I’m a bit lost on how the thumbnail attribute in Dashboard → System and settings - > Thumbnails, is working. I’ve set a custom thumbnail there with the size I want and a handle. But how do I assign that attribute to a page? It does not show up in the attributes list. And when I create a custom attribute with the same handle, it does not change the size of the image. What am I missing or doing wrong?
This is the code I use to load the thumbnail into the page template
If you are getting original image url, even with providing correct thumbnail handle, then maybe thumbnail is not generated at all.
On Concrete 9 o to File Manager and click “…” after hovering file to show image “Details”.
Click “Thumbnails” to see if they are actually created.
If not Click “Rescan”.
If thumbnails are still not created, then probably your uploaded image is too big and your server doesn’t have enough memory to be able to generate it. In that case replace image with smaller version.
You can enable browser-side resizing during upload in dashboard:
Set with and height to something sane, like 1920 x 1080 px and your server should handle images flawlessly.
I’ve checked the image and the correct thumbnail is generated so that is working. I’m just still confused how to get the uploaded image selected as the correct attribute for the individual page. So what I did is the following:
Set a thumbnail in dashboard → system → thumbnails with handle ‘thumbnail_news’
Created a image attribute in dashboard → pages & themes → attributes with handle ‘thumbnail_news’
Uploaded a image trough the attributes settings of a page
Checked if the uploaded image has indeed a thumbnail generated in the file system, which is true
Used the code in original post to load in the image
Checken the source shows it does not use the thumbnail source file but the original uploaded version.
So I have two problems I’m trying to figure out.
How can I solve the issue that it does use the correct thumbnail version
How can I use this method to load different thumbnail sizes based on that 1 attribute. (1 size for a page list and 1 for a hero image on the page itself)
I’ve solved the issue. The original code was wrong. The version was set to ‘small’ which I did not create. Changing that to the ‘news_thumbnail’ did the trick. This is also the method of using different sizes for it.
One last question; how can I load/use the retina version that gets generated? Solved: Using the ‘_2x’ behind the handle name will use the retina version.