simonsays Posted October 11, 2018 Share Posted October 11, 2018 Hello, Moved this topic from "Modules". Put that there by mistake. to avoid caching I am trying to end up with a hook to append page->modified timestamp to all image urls. NB! I am aware of noCacheUrl method, but this one's no good as I want them to be out of cache on page update only. NBB! I have tried CustomUploadNames module but it breaks the image path when cropping images inside the repeaters. NBBB! Ideally it would be image->modified timestamp, which is unfortunately not updated on crop or focus. I have come up with something like wire()->addHookAfter('Pageimage::url', function($event) { $page = $event->object->get('page'); $p = ($page instanceof RepeaterPage) ? $page->getForPage() : $page; $event->return = $event->return . '?nc=' . $p->modified; }); This one has several issues though... 1) I end up with multiple appends, eg. ?nc=321223242?nc=4232424342323, etc 2) Page modified date is not updated when cropping an image (unless saving it afterwards, which is an overkill imho). Can anyone think of a better solution for that? Link to comment Share on other sites More sharing options...
adrian Posted October 11, 2018 Share Posted October 11, 2018 Sorry for the delay in response to the CustomUploadNames issue - I am on semi-vacation, but I will try to take a look at that soon so maybe that will address your needs? Link to comment Share on other sites More sharing options...
simonsays Posted October 12, 2018 Author Share Posted October 12, 2018 12 hours ago, adrian said: Sorry for the delay in response to the CustomUploadNames issue - I am on semi-vacation, but I will try to take a look at that soon so maybe that will address your needs? Take your time, man. You are not paid for this ? I was just looking for a temporary solution while you fix your module. 1 Link to comment Share on other sites More sharing options...
adrian Posted October 12, 2018 Share Posted October 12, 2018 On 10/12/2018 at 2:20 AM, simonsays said: 1) I end up with multiple appends, eg. ?nc=321223242?nc=4232424342323, etc It should be easy enough to remove the first one when adding a new one by stripping off the ? and everything after it. On 10/12/2018 at 2:20 AM, simonsays said: 2) Page modified date is not updated when cropping an image (unless saving it afterwards, which is an overkill imho). You can hook into Pageimage::crop Link to comment Share on other sites More sharing options...
simonsays Posted October 22, 2018 Author Share Posted October 22, 2018 On 10/12/2018 at 11:51 PM, adrian said: It should be easy enough to remove the first one when adding a new one by stripping off the ? and everything after it. You can hook into Pageimage::crop Thank you very much, I'll try (been on a holiday myself). I'd rather use your module instead, though... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now