carnelianwoods
Forum Replies Created
-
Forum: Plugins
In reply to: [Phoenix Media Rename] Original of scaled file lost after renameGetting closer. As mentioned above, “-scaled” is a reserved filename suffix for WP. It’s hard to know what unexpected issues might come up if filenames can be changed to “-scaled” that are not actually scaled and thus don’t have the directory structure with an original image (without “-scaled”) and a “-scaled” version of the image, and thumbnails without the “-scaled” suffix.
The user can add the “-scaled” suffix to the filename if the remainder of the filename is unique. This results in:
Original image: contains “-scaled” suffix
Displayed filename in right panel: contains “-scaled-scaled” suffix
Filename: contains “-scaled” suffixThis may also be confusing to the user (or more so a subsequent user), despite it being their action, since a “-scaled” filename suffix has a specific meaning in WP.
Forum: Plugins
In reply to: [Phoenix Media Rename] Setting does not work as documentedAlso, while it does force lowercase on the filename, it does not on the “Original image” filename displayed on the right panel. While the case change should not be happening here at all, possibly the usage with “Rename from post” would have the same issue.
Before rename:
Filename: Lawn-and-Flowers-at-Lodge.gif
Original image: Lawn-and-Flowers-at-Lodge.gifAfter rename:
Filename: lawn-and-flowers-at-lodge-first.gif
Original image: Lawn-and-Flowers-at-Lodge-first.gifForum: Plugins
In reply to: [Phoenix Media Rename] Original of scaled file lost after renameStill broken. I’ll document that more in another post.
Since WP does not offer a rename function, you get to define what that behavior means, but the “Principal of Least Surprise” should apply. That means, behaviors should be intuitive and expected, and respect WP’s behaviors.
The filename suffix “-scaled” is essentially a “reserved spelling” to WP, and has special meaning. Since PMR allows file renaming, it should try to prevent the user from corrupting WP with their action. The “sanitize filename” option is an example of an excellent feature that does just that. WP itself prevents collisions with “-scaled” on upload by appending “-1” to the filename so that no filename can be created by the user with a “-scaled” suffix, e.g., uploading filename-scaled.gif becomes filename-scaled-1.gif and creates the scaled version filename-scaled-1-scaled.gif.
The plugin code appears now to remove “-scaled” from the filename *before* it is displayed to the user in the Filename field. In addition to allowing a bug (described in another post), WP displays the filename in the medial library page and in the edit media page, right column, with “-scaled”.
For UI consistency, either the filename entry field needs to be called “Original image name” (which for other reasons can be confusing), or the filename displayed should not have “-scaled” removed. The “-scaled” needs to be removed internally *after* the user clicks Update and process from there. It’s possible that internally it needs to keep both versions for appropriate use internal cases to make the code come out right and not end up with the “Original image” having “-scaled” or ending up with “-scaled-scaled” in the filename. I don’t know where the codes functions are handed back and forth from WP to the plugin, so maybe this isn’t possible.
Forum: Plugins
In reply to: [Phoenix Media Rename] Original of scaled file lost after renameI think almost all of these issues will be fixed with:
- don’t force filename to lower case
- preg_replace(‘/-scaled$/’, ”, $filename) used to strip “-scaled” from the entered filename before doing anything else. Use the result as the new filename in the remainder of the code.
- use the regex above on the original file name and the entered filename to decide if it has changed. If no change, do nothing.
Not sure what to do with the thumbnail issue. You can probably use a regex to find the thumbnails, maybe as a settings option, if it seems they are not registered. Not clear why the system can delete them if they are not registered. Look at the WP source? I found a place in the GoodLayers plugin settings where some of the thumbnail sizes that appear are set, but it and the WP settings were not all the thumbnail sizes.
Hope this helps.
Forum: Plugins
In reply to: [Phoenix Media Rename] Original of scaled file lost after renameStill very broken. Original image filename is handled better, but the code is more broken. I’ll post a suggested fix in another post.Here is the test sequence, as above:
First, upload a file with too much resolution.
Upload Folder Before Rename
Lawn-and-Flowers-at-Lodge-AAAxBBB.gif (eleven files)
Lawn-and-Flowers-at-Lodge-scaled.gif
Lawn-and-Flowers-at-Lodge.gif
Displayed “Original image”: Lawn-and-Flowers-at-Lodge.gifUpload Folder After Rename
Lawn-and-Flowers-at-Lodge-AAAxBBB.gif (eleven files)
lawn-and-flowers-at-lodge-first-scaled-AAAxBBB.gif (eleven files)
lawn-and-flowers-at-lodge-first-scaled-scaled.gif
lawn-and-flowers-at-lodge-first-scaled.gifDisplayed “Original image” after rename: Lawn-and-Flowers-at-Lodge-first-scaled.gif
Filename after rename: lawn-and-flowers-at-lodge-first-scaled-scaled.gifIssues:
- original thumbnails not renamed (should be renamed)
- renamed thumbnails are “-scaled” (should not have “-scaled” in name)
- new filename forced to lower case (should not change case)
- full resolution file name is in lower case and “-scaled” (should be renamed in the entered case and no “-scaled”)
- displayed “Original image” filename has “-scaled” (should not have “-scaled”)
- filename entry field is now lowercase and “-scaled-scaled” (should only have one “-scaled”)
Changed behaviors from prior version:
- full resolution file is now renamed, but incorrectly
- scaled file is now named “-scaled-scaled”
- displayed “Original image” is renamed properly caps and lowers as entered, has a file type, and link works (but still has “-scaled”).
If I now click update with no changes, there are no changes. (expected)
If I now delete the “-scaled-scaled” from the filename and click update, I get:
Lawn-and-Flowers-at-Lodge-AAAxBBB.gif (eleven files)
lawn-and-flowers-at-lodge-first-scaled-AAAxBBB.gif (eleven files)
lawn-and-flowers-at-lodge-first-1-scaled-AAAxBBB.gif (eleven files)
lawn-and-flowers-at-lodge-first-1-scaled.gif
lawn-and-flowers-at-lodge-first.gifDisplayed “Original image” after rename: lawn-and-flowers-at-lodge-first.gif
Filename after rename: lawn-and-flowers-at-lodge-first-1-scaled.gifIssues:
- Issues as above
- A “-1” is added by the system to the filename to resolve a duplicate name conflict. Removing the “-scaled” that will be added back by the system is not a filename change. If removing “-scaled” is the only change to the filename then Phoenix File Rename should do nothing.
Clicking Delete Permanently from the Media Library deletes all of the renamed files, including the thumbnails, but not prior thumbnails that did not get renamed. Something in the system can determine the thumbnails associated with the original image so I’d expect that Phoenix File Rename could do that rename correctly also.
Starting with a new upload again:
Upload Folder Before Rename
Lawn-and-Flowers-at-Lodge-AAAxBBB.gif (eleven files)
Lawn-and-Flowers-at-Lodge-scaled.gif
Lawn-and-Flowers-at-Lodge.gif
Displayed “Original image”: Lawn-and-Flowers-at-Lodge.gifEdit filename to remove only “-scaled” from name.
Upload Folder After Rename
Lawn-and-Flowers-at-Lodge-AAAxBBB.gif (eleven files)
lawn-and-flowers-at-lodge-1-scaled.gifDisplayed “Original image” after rename: Lawn-and-Flowers-at-Lodge.gif
Filename after rename: Lawn-and-Flowers-at-Lodge.gifERROR box:
“File renaming error! Tried to copy /Users/george/Local Sites/carnelian-woods/app/public/wp-content/uploads/2023/03/Lawn-and-Flowers-at-Lodge.gif to /Users/george/Local Sites/carnelian-woods/app/public/wp-content/uploads/2023/03/Lawn-and-Flowers-at-Lodge.gif”Issues:
- thumbnails not created
- original image lost
- plugin is forcing filename to lower case
- rename is attempted when it will have no effect as system will add “-scaled” back.
Forum: Plugins
In reply to: [Phoenix Media Rename] Original of scaled file lost after renameDoes the new major version number indicate significant new features? Or incompatible changes? I haven’t noticed if you supply APIs. Are you familiar with semver.org (Semantic Versioning, mostly for APIs)?
After this is fixed, how do I get the dozen or so scaled images I have to restore WP’s “original image” to the correct (not scaled) file?
Forum: Plugins
In reply to: [Phoenix Media Rename] Original of scaled file lost after renameFor the “Serialize filename if it exists” in options, the example shows only a numeral added, e.g., “phoenix.png” to “phoenix1.png”. My test had a dash also added, e.g. to “phoenix-1.png”.
In any event, I don’t have the option checked, so either it is active without the checkmark or something else is adding the “-1”. Note that if I upload a file with the same name twice (no Phoenix File Renamed used), a “-1” is added on upload the second time, so possibly this is WordPress doing the work.
- This reply was modified 2 years ago by carnelianwoods.
Forum: Plugins
In reply to: [Phoenix Media Rename] Original of scaled file lost after renameNote that I was incorrect that the original unscaled image file was lost, at least on the two test files I tracked down. These had radically different filenames (originals were a long sequence of hex digits) and were hard to track down.
I went through a sequence of operations below to test the behavior of 3.9.0 and 3.9.1 and more fully document the problem. Note that I don’t see any difference in behavior in the upload folder. There are other issues, however, see below.
—–
Phoenix File Rename 3.9.0 and 3.9.1
First, upload a file with too much resolution.
Upload Folder Before Rename
Lawn-and-Flowers-at-Lodge-AAAxBBB.gif (eleven files)
Lawn-and-Flowers-at-Lodge-scaled.gif
Lawn-and-Flowers-at-Lodge.gif
Displayed “Original image”: Lawn-and-Flowers-at-Lodge.gifFilename box entered:
Lawn-and-Flowers-at-Lodge-first-scaled
Click UpdateUpload Folder After Rename
Lawn-and-Flowers-at-Lodge-AAAxBBB.gif (eleven files)
lawn-and-flowers-at-lodge-first-scaled-AAAxBBB.gif (eleven files)
lawn-and-flowers-at-lodge-first-scaled.gif
Lawn-and-Flowers-at-Lodge.gif
Displayed “Original image”: lawn-and-flowers-at-lodge-first-scaled (no file type extension)Issues:
- original thumbnails not renamed (separate issue?)
- thumbnails are “-scaled”
- new filename forced to lower case (not what was entered)
- Displayed “Original image” filename has “-scaled” and no file type extension. Clicking link generates a 404 error because of missing extension.
- old original filename (unscaled) is not renamed
If I now click update with no changes, there are no changes. (expected)
If I now delete the “-scaled” from the filename and click update, I get:
Lawn-and-Flowers-at-Lodge-AAAxBBB.gif (eleven files)
lawn-and-flowers-at-lodge-first-scaled-AAAxBBB.gif (eleven files)
lawn-and-flowers-at-lodge-first-1-scaled-AAAxBBB.gif (eleven files)
lawn-and-flowers-at-lodge-first-1-scaled.gif
Lawn-and-Flowers-at-Lodge.gifA “-1” is added by the system to the filename to resolve a duplicate name conflict, but should it? Removing the “-scaled” that will be added back by the system is not really a filename change. If removing “-scaled” is the only change to the filename then Phoenix File Rename should do nothing.
Clicking Delete Permanently from the Media Library deletes all of the renamed files, including the thumbnails, but not the original file or original thumbnails that did not get renamed. Something in the system can determine the thumbnails associated with the original image so I’d expect that Phoenix File Rename could do that rename correctly also.
I hope the above is useful.
Forum: Plugins
In reply to: [Phoenix Media Rename] Thumbnails not renamedThat page contains only code to ask for max width and height for:
thumbnails, currently 150×150
medium, currently 300×300
large, currently 1024×1024
Which looks like the WP defaults page.
Are the other sizes I’m seeing then “not registered”, or do they come in someplace else?Forum: Plugins
In reply to: [Phoenix Media Rename] Original of scaled file lost after renameI understand that WP adds the “-scaled” suffix and does its work. Thanks.
The problem is that the original filename in the side panel is now also “-scaled” and a version of the file without “-scaled” not longer exists in the uploads folder. Clicking on the original filename link then generates a 404 error. Adding the file type to the url allows access to the file, but it is still the “-scaled” file. So it looks like the original is permanently lost.
My guess is
– the new filename is captured after “-scaled” is added and all files with the old base name (with or without “-scaled”) are renamed to the new name with “-scaled”. This loses the “original” unscaled file.
– the “original filename” field is updated to the new filename with “-scaled” instead of just the base filename. The “original” unscaled file is lost above, though, so there would be no file of this unscaled name still existing.
– when updating the “original filename” that the file type is being lost.- This reply was modified 2 years ago by carnelianwoods.
- This reply was modified 2 years ago by carnelianwoods.
Forum: Plugins
In reply to: [Phoenix Media Rename] Thumbnails not renamedI’m new to WordPress but happy to help debug this. How do I determine what sizes are registered?
If it helps, looking at the media files, for example one file I renamed had these sizes both before and after the rename:
150×150, 300×200, 300×368, 600×346, 600×366, 600×389, 768×513, 1024×684, 1280×700, 1536×1025