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

Issue with direct links to files in Folder

Started by Muut Archive 12 years ago · 4 replies · 300 views
12 years ago

Pardon if this is a repost. I searched but could not find a solution. I have a page created for a project of mine. It is located in user/pages/05.project/photographs-of-saint-john/default.md

in this folder I have another folder containing images with a sub folder for /thumbs/ and /full/ which are for the projects thumbnails and full size images.

Now if i link to a thumbnail file directly for example :

http://www.mikecapson.com/project/photographs-of-saint-john/images/thumbs/Fairview-Bowling-Lanes-Saint-John.jpg

It gives me the same image as if I goto the full size version here :
http://www.mikecapson.com/project/photographs-of-saint-john/images/Fairview-Bowling-Lanes-Saint-John.jpg

I am not sure if I cannot use direct links within grav like above or perhaps should be sticking to using {{ relative_url }}?

Any help or lead would be appreciated!

12 years ago

That's interesting. Something is definitely up there. It's related to this 'fallback' functionality we have when a Grav route is not found.

Basically URLs in the user folder are a routed as pages first. Then if that page is not found, we make an attempt to see if you were trying to reference a file that exists. I will look at this logic to see if anything is amiss that could be causing this problem you are seeing.

An alternative would be to setup a directory at the root of grav that would not be routed, for example /project-images and just reference those images directly with via /project-images/project-x/image-1.jpg

However, what you are trying to do is not ideal. The better solution would be to put the images in the folder directly with the page. Then you could use Grav's media capabilities to dynamically create the thumbnail as needed.

Unless you have some good reason not to use Grav's built in image hand ling, I strongly suggest doing so as it will automatically route to the image without any pathing needed, and gives you complete control over manipulating that image without the need of pre-processing it manually.

12 years ago

Ok. I will try that out then. Thanks,
Mike

12 years ago

FYI, if you were to drop an image called "image-x.jpg" into the your user/pages/05.project/photographs-of-saint-john/ folder, from your page you could access it directly and resize it to a thumbnail like this:

TXT
![](image-x.jpg?cropResize=200,200)

The Media Page on learn.getgrav.org has many more examples of the kinds of things you can do.

12 years ago

Awesome. Thus eliminating my need for thumbnails. Good idea. Thanks!

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