I'm generating base64 encoded strings of very small image transforms to display a blurred version of images while the bigger asset is loading.

I'm trying to get the cached transform path (if it already exists) as I need to extract the actual file content via file_get_contents().

I tried this:


But this returns the original asset path, so setTransform is ignored.

The workaround I currently use is:

$url = $asset->getUrl('rendition8');
$baseUrl = UrlHelper::siteUrl();
$imgUrl = str_replace($baseUrl, '/', $url);
$fullPath = Craft::getAlias('@storage') . $imgUrl;

Which is not great...

Is there any other asset method I'm missing? Maybe it just doesn't exist because the transformed resource might not be generated yet?


1 Answer 1


There’s a discussion on that question, here at Stackexchange. There I wrote:

It’s not possible to get a dataUrl from a resized asset at this time, not even in Craft 4.

There’s already an issue for that: https://github.com/craftcms/cms/discussions/11388.

In an older, closed issue, the reason is explained: https://github.com/craftcms/cms/issues/10108.

It is said to be possible with the Imager X plugin. And there is a dedicated Blur Hash Plugin.

However: We are discussing and testing it currently. Best will be to read the discussion.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.