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

Media (image) actions don't work

Started by Muut Archive 12 years ago · 7 replies · 588 views
12 years ago

I've been tinkering with Grav for an evening or two. Nice. I'm pretty sick of Joomla and want something simpler. Grav looks like a good option so far.

I can't get image resize or cropResize to work. Here are a couple of copy/pastes of my non-working commands:


The images just stay their normal 900,600 size. What am I missing?

12 years ago

Media functions only work on images that are associated with pages. Not just arbitrary images in an images/ directory under user. If you had them under user/pages/images then you could reach them and resize them with /images/mpr121_012sm.jpg?resize=300,200

Ideally you should put the images for a specific page, in the actual page folder. So if you are on page somwhere/else/page, then put the image in that same folder and just access/manipulate them with:

TXT
![](myimage.jpg?resize=300,200)

No paths needed!

12 years ago

Ah! Thank you.

I had been planning, as you say, on moving the page's images into the page directory anyway. Guess I'll get that done now.

11 years ago

Not working for example default page in path
/user/pages/01.home/sample-image.jpg
/user/pages/01.home/images/sample-image.jpg
/user/pages/images/sample-image.jpg
/user/images/sample-image.jpg
/images/sample-image.jpg

how folder path need for picture?
Example please

11 years ago

if delete cash folder resize not working. If add {{ dump(page.media['sample-image.jpg']) }} again work.

11 years ago

As stated in the earlier post, the image needs to be associated with a page for it to be treated as page media and therefore, have the media functions work correctly.

So your first 3 examples could work, while the last 2 (not inside user/pages) will not work:

for /user/pages/01.home/sample-image.jpg, if you were in on the home page you could just use ![](sample-image.jpg?resize=300,200)

for /user/pages/01.home/images/sample-image.jpg if you were on the home page again, you would have to put a path: ![](/home/images/sample-image.jpg?resize=300,200)

For /user/pages/images/sample-image.jpg similar to above you need to reference the full path, but because it's in user/page it will still work: ![](/images/sample-image.jpg?resize=300,200)

11 years ago

I think you have installed grav inside a directory or i don't know, btw you can try to apply this commit and use the standard markdown text:

TXT
![](sample.jpg?resize=300,300)

and put sample.jpg in the same page folder.

The commit: https://github.com/getgrav/grav/pull/114

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1319 9 years ago
Archive · by Muut Archive, 9 years ago
2 915 9 years ago
Archive · by Muut Archive, 9 years ago
2 4045 9 years ago
Archive · by Muut Archive, 9 years ago
1 2920 9 years ago
Archive · by Muut Archive, 9 years ago
3 1104 9 years ago