0

I have a private image with this URL.

http://mystite.com/system/files/images/IMG_0371_24.jpg/IMG_0371_24.jpg

An image style is created for the above image on location

http://mysite.com/system/files/styles/square/private/images/IMG_0371_24.jpg/IMG_0371_24.jpg

The problem is when I display the original image, it works fine. But when I display the image with style, the image is not displaying and in the console, I get 404.

When I try to access the original image through the browser, I can access the image. But when I try to access the image with style in the browser, I get the The requested page could not be found.

I can confirm the image is present in the specified location. But don't know what is the issue.

Can anyone tell what can be the issue?

0

I found the solution.

Actually, the problem is that the image style URLs need an ITOK at the end of the URL.

So for that, I used the buildUrl function from the image style.

$image_style_url = $image_style->buildUrl($original_image_uri);

Now this gives a URL like this

http://mysite.com/system/files/styles/square/private/images/IMG_0371_24.jpg/IMG_0371_24.jpg?itok=p2-MBbc

And now with that URL, I can access the image with an image style.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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