Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Archive

How to get the original image URL

Started by Muut Archive 9 years ago · 2 replies · 1582 views
9 years ago

I'm creating a gallery similar to the cookbook example but find myself unable to retrieve the URL of the original image after having called methods on the object.

I tried the .url(false) approach suggested in the media section, but this returns a URL to a compressed version of my file, not the path to my original file that image.url returns before being tempered with.

TWIG
1. {{ image.url }} | {{ image.cropZoom(250, 250).url }} -> original | cropped
2. {{ image.cropZoom(250, 250).url }} | {{ image.url }} -> cropped | compressed-original
3. {{ image.cropZoom(250, 250).url }} | {{ image.url(false) }} -> cropped | compressed-original
4. {{ image.cropZoom(250, 250).url(false) }} | {{ image.url }} -> cropped | cropped

What's the deal with that?

9 years ago

If you are just trying to display the image from page media use this.

TWIG
{{ image }}

That will render the image and you don't need to put it inside of a <img/> tag.

And for cropped images, use

TWIG
{{ image.cropZoom(width, height).html }}

That will output the image, also not needing a <img/> tag.

9 years ago

Yes, I'm aware of that. It might be however be desirable to assemble customized HTML, so knowing how to change the order would be helpful. And the documentation should not tell falsehoods (as I have encountered several times already).

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1282 9 years ago
Archive · by Muut Archive, 9 years ago
2 889 9 years ago
Archive · by Muut Archive, 9 years ago
2 4019 9 years ago
Archive · by Muut Archive, 9 years ago
1 2894 9 years ago
Archive · by Muut Archive, 9 years ago
3 1078 9 years ago