douglas81 Posted October 29, 2014 Share Posted October 29, 2014 I would like to put a few page images through third party image processing tools via php's exec() function. This will generate a new file which I would like to store in the same folder as the original. If I should ever delete the original image, I don't want to be left with orphaned variations. So what naming conventions or procedures must be in place that will allow these image variations to be deleted if I should choose to delete the original through the admin? Link to comment Share on other sites More sharing options...
douglas81 Posted October 29, 2014 Author Share Posted October 29, 2014 From my own research, it seems like appending something thus... "originalimagename.appended.jpg" ... doesn't work. It seems like we need to have dimensions after the originalname, so... "originalname.600x400-appended.jpg" works fine. However, "originalname.600x400.appended.jpg" doesn't work. It seems that apart from the final period before the file extension, we can only have only one extra period and that must directly precede the image dimensions. I guess that's just how the regex is working, right? So, I've determined this... I can modify the filename however I want, so long as there is one period directly after the original file name, and the first info after that added period is the image dimension, and directly after the image dimensions before any appended info, we must have a dash. Sound about right? Also, it seems like I can't have the @ symbol in there. Which is a shame as I sometimes like to use that for "retina" optimised images. Any other limitations and/or naming conventions I should know about? Link to comment Share on other sites More sharing options...
Jan Romero Posted October 29, 2014 Share Posted October 29, 2014 I’m not fully certain what you are trying to do exactly. Have you seen this thread about deleting orphaned image files? Link to comment Share on other sites More sharing options...
douglas81 Posted October 29, 2014 Author Share Posted October 29, 2014 Hey Jan, Ha ha... yeah, it's sometimes tricky to explain what I'm trying to do...! Basically, as you'd expect, I have image fields in a few of my templates. But I also have a separate php script running outside of the usual ProcessWire stuff which processes those images that were uploaded to PW's assets folder via the image field. When a user deletes the original image, I just want to make sure these modified images are automatically found and also get deleted. It seems like there are specific rules about how I must rename the processed files in that case. That's what I'm trying to work out. Link to comment Share on other sites More sharing options...
adrian Posted October 29, 2014 Share Posted October 29, 2014 I know horst will have some great advice shortly, but for now, have a read of this: https://processwire.com/talk/topic/6667-jpegoptimimage/ This module also uses the an exec command and also names the files differently. My first post there notes the issue with images being left behind and mentions that you can extend Pageimage::isVariation to deal with these. I know that horst has been working on some standard naming conventions to make this all a lot easier - again, I am sure he'll enlighten you shortly 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