Skip to main content
13 votes

How do image focal points work in Craft 3?

While we’re piggybacking, here’s a snippet that goes one step further and generates the necessary CSS to position an untransformed image: {% set img = entry.headingImage.one %} {% if img %} {% ...
Dom Stubbs's user avatar
8 votes
Accepted

Can you prevent upscaling when using Craft's image transforms?

As found here, this actually seems to be a requested feature that is not yet implemented. However, in the link given, Brandon also supplied a workaround for the time being: {% set transform = { width:...
justussimon91's user avatar
7 votes
Accepted

Image transform is turning my jpegs dark

Setting 'preserveImageColorProfiles' => true, in craft/config/general.php solved the problem. https://craftcms.com/docs/config-settings#preserveImageColorProfiles Note that you need to be running at ...
patrick.altair's user avatar
6 votes
Accepted

What are the best practices for the development setup?

That's the setup we use here. It's ok, but local development runs slowly because the database is off-site - we'll be moving to an internal database server in the new year because of that. Image ...
Matt Wilcox's user avatar
  • 3,209
6 votes
Accepted

How do image focal points work in Craft 3?

Focal points are used mainly for when Asset transforms (i.e. cropping) are performed in Craft. They tell Craft where it should focus on the image when performing these actions.
Brad Bell's user avatar
  • 67.5k
6 votes
Accepted

Craft CMS images transform srcset sizes

You can use the method Asset::getSrcset to generate a valid srcset attribute as well as the asset transforms included in it. But you will need to restructure your HTML a bit. The current approach ...
MoritzLost's user avatar
  • 11.5k
5 votes
Accepted

Is it possible to get a transformed image's file size (bytes, not dimensions)?

I don't think it's possible to get the file size of an image after it's been transformed with Craft's out-of-the-box image transforms. It looks like the .size property only works on the original ...
Alex Roper's user avatar
  • 2,642
5 votes
Accepted

How to reprocess image transforms that already exist in the database

You can run ./craft clear-caches/transform-indexes to clear your transform indexes.
Oli's user avatar
  • 7,495
5 votes
Accepted

image transform to webp image format

If you're not seeing WebP as a format option, your server doesn't support webp. As per the server requirements for Craft, you need either of the PHP extensions for images, GD or ImageMagick. Both of ...
MoritzLost's user avatar
  • 11.5k
4 votes
Accepted

Transform cannot be found

Remove the single quotes around wideCrop. <img class="full" src="{{ image.getUrl(wideCrop) }}"> Details for why the difference in "template defined" transforms here:
AbbeyDesign's user avatar
  • 1,527
4 votes
Accepted

Image Transforms: Is there a way to detect portrait or landscape?

The best way would be to use the Fit image transform. Set the transform to 'Fit' and set both your width and height values to 1000px. That way the image will continue to scale until the first longest ...
Jamie Wade's user avatar
  • 3,644
4 votes

Using Focuspoint with eager loading

After some research I found out that this problem has no simple solution (unfortunately). Check https://github.com/smcyr/Craft-FocusPoint/issues/10. A solution would be not to use eager loading (...
Mr. Sam's user avatar
  • 287
4 votes
Accepted

Why are gif transform file sizes very large?

No Current Good Solution Having liaised directly with Craft Support on this issue, the outcome after a bit of research was that there is not currently any good solution. Apparently, Imagick is ...
Mike Vaux's user avatar
  • 480
4 votes

Applying an image transform returns a 404 cpresources URL

For what it's worth, I also had his issue, turned to imager, which gave me some more useful error messages as to my root cause of the issue: You may need to make sure that the path to the asset file ...
Toby Stokes's user avatar
4 votes

Can you prevent upscaling when using Craft's image transforms?

As of Craft 3.4 you can set upscaleImages to false in general config: https://craftcms.com/docs/3.x/config/config-settings.html#upscaleimages
James Smith's user avatar
  • 5,344
4 votes

What are the best practices for the development setup?

Matt Wilcox alluded to it in his original comment, but something like Craft-Scripts will really help out with this workflow. You can read more here: Database & Asset Syncing Between Environments ...
andrew.welch's user avatar
  • 11.6k
4 votes
Accepted

Set max-height on image transforms?

You can pass an array instead of the image-transform handle to the getUrl() function {% set transform = { 'width' => 600, 'height' => (asset.getWidth() <= 800)? asset.getWidth() : ...
Robin Schambach's user avatar
4 votes
Accepted

Transform image in webp and get srcset

Yes you can – assets include a getSrcSet method which will generate all the requested image sizes and return a srcset string. This method accepts an image transform which can include the desired ...
MoritzLost's user avatar
  • 11.5k
3 votes
Accepted

Image Transform Problems, Timeouts, Stuck Transforms

Craft release 2.6.2911 has made a significant improvement, and with it, our troublesome animated GIFs are transforming correctly.
Jay Haase's user avatar
  • 265
3 votes
Accepted

Force an image transform to images inserted into Redactor

I wrote a plugin called Retcon which is able to apply bulk image transforms to images in HTML/Redactor content: {{ entry.body|retconTransform({ width : 1024 }) }} {{ entry.body|retconTransform(...
Mats Mikkel Rummelhoff's user avatar
3 votes

PHP transformed image?

$entry->featuredImage[0]->getUrl('small'); works.
Jamie's user avatar
  • 151
3 votes
Accepted

Is it possible to force Craft to recheck available sever modules?

Craft will re-run the requirement checks simply by loading that admin/utils/serverinfo page. The results aren't cached. It sounds like your box may have had the ImageMagic library installed, but not ...
Brad Bell's user avatar
  • 67.5k
3 votes

Is it possible to clear caches and re-index assets programattically?

Updated Craft version 3+ now has console commands built in that can handle these tasks. $ php craft clear-caches/all $ php craft index-assets/all See documentation for Console Commands in 3.x or ...
Alex Roper's user avatar
  • 2,642
3 votes

Is it possible to compress image transforms?

Yes, you can do this if you use the Imager plugin. Here's how: Creating Optimized Images in Craft CMS
andrew.welch's user avatar
  • 11.6k
3 votes

Is there a way to manually trigger an asset transform before calling getUrl()?

You could use my Preparse Field plugin to generate transforms when an entry (or any other element) is saved. Create a preparse field and create some twig that makes the same transforms that you do ...
André Elvan's user avatar
  • 7,288
3 votes

How do I force Craft to regenerate assets transform?

Let me add, for those like me who just moved to a different server, before you dump the table, make sure your assets directory is writable by Craft. I did what Lindsey D suggested, and it recreated ...
David Rhoden's user avatar
3 votes

Is there a way to force Assets to redo transforms?

I found that a really easy way to rebuild transitions is to simply change the transform settings in the craft admin interface. For example maybe your transform is to 400 pixels, change it to 200 ...
Clark's user avatar
  • 31
3 votes

What accurately will set asset paths for multilingual sites?

Great answer above: https://craftcms.stackexchange.com/a/30/1056 Works like a charm. But for multiple environments it can get pretty nasty to set up the file system for each environment individually. ...
medoingthings's user avatar
3 votes

Prevent Asset Transforms from scaling Image past 100%

Here's a slight revision that checks widths and heights and ensures that the output has no white space: {%- macro imageURL(image, transform) -%} {% spaceless %} {% if image.getWidth > ...
Dom Stubbs's user avatar
3 votes

Image Transforms - Image not processed until second page refresh

I'm having this problem too. This can't be expected behaviour, can it? EDIT (SOLVED): I've learned from MildlyGeeky in the Craft Discord server that this issue is caused by Twig being picky about ...
user2157969's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible