Conversation
parabrola
suggested changes
Jun 25, 2020
parabrola
reviewed
Jun 29, 2020
Comment on lines
401
to
410
| if ( false !== strpos( $public_id, '/' ) ) { | ||
| // Split the public_id into path and filename to allow filtering just the ID and not giving access to the path. | ||
| $public_id_info = pathinfo( $public_id ); | ||
| $public_id_folder = trailingslashit( $public_id_info['dirname'] ); | ||
| $public_id_file = $public_id_info['filename']; | ||
| } else { | ||
| // File is in the root of cloudinary. | ||
| $public_id_folder = ''; | ||
| $public_id_file = $public_id; | ||
| } |
Contributor
There was a problem hiding this comment.
Maybe we can switch to this in order to satisfy linters:
Suggested change
| if ( false !== strpos( $public_id, '/' ) ) { | |
| // Split the public_id into path and filename to allow filtering just the ID and not giving access to the path. | |
| $public_id_info = pathinfo( $public_id ); | |
| $public_id_folder = trailingslashit( $public_id_info['dirname'] ); | |
| $public_id_file = $public_id_info['filename']; | |
| } else { | |
| // File is in the root of cloudinary. | |
| $public_id_folder = ''; | |
| $public_id_file = $public_id; | |
| } | |
| // File is in the root of cloudinary. | |
| $public_id_folder = ''; | |
| $public_id_file = $public_id; | |
| if ( false !== strpos( $public_id, '/' ) ) { | |
| // Split the public_id into path and filename to allow filtering just the ID and not giving access to the path. | |
| $public_id_info = pathinfo( $public_id ); | |
| $public_id_folder = trailingslashit( $public_id_info['dirname'] ); | |
| $public_id_file = $public_id_info['filename']; | |
| } |
Contributor
Author
There was a problem hiding this comment.
@dugajean Nice idea. I usually do prefer to have a default, and if it's not what's expected then change.
parabrola
approved these changes
Jun 29, 2020
Contributor
|
LGTM |
pereirinha
approved these changes
Jun 30, 2020
Contributor
pereirinha
left a comment
There was a problem hiding this comment.
Thanks, @DavidCramer for the hard work on this one.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Allows for being able to alter the public_id for uploading as well as correcting the folder changing sync.
Testing notes.
This allows for changing the public ID of assets.
Below is an example of using the filter
cloudinary_upload_optionsto use the assets slug as it'spublic_idAdd the snippet in the
functions.phpin your theme.go to the media library page. If all assets slug is the same as the ID (it should be), then the cloud should be green.
Edit an asset, and change the slug (you may need to select Screen Options, and enable it).
Update and go back to the media library. The image should now be in the syncing state (orange cloud).
After a moment, it should be green and the public ID should be the same as the slug.