-
Notifications
You must be signed in to change notification settings - Fork 31
Implement Image and Text Overlays #1111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
…ns are enabled by default
gabrielcld2
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor things I've noticed, otherwise the code looks really good 👍
|
|
||
| // Check if file exists and is an SVG. | ||
| if ( ! file_exists( $file_path ) || 'svg' !== pathinfo( $file_path, PATHINFO_EXTENSION ) ) { | ||
| return $echo ? '' : ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick (if-minor): If I'm understanding this line correctly, it always returns an empty string, so we could change it to simply return '';
Same issue a few lines below
| <?php | ||
| if ( ! empty( $transformations ) ) { | ||
| echo 'cld_transformations__icon--active';} | ||
| ?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (non-blocking): Maybe we could use a variable to store that class name conditionally, that could make this a bit more readable in my opinion. Something like:
<?php $transformation_active_class = ! empty ( $transformations ) ? 'cld_transformations__icon--active' : ''; ?>
<span class="cld_transformations__icon <?php echo esc_attr( $transformation_active_class ); ?>">The current approach works fine though. I simply find it harder to to read because we're doing multi line PHP within a class names declaration, but it might be a personal preference 🙂
Same thing for the other two <span> elements below
| } | ||
|
|
||
| .cld-ui-suffix { | ||
| margin-left: 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (non-blocking): Would it be worth using logical properties e.g. margin-inline-start for the CSS? I assume that would make it easier to potentially support RTL languages.
Note: this doesn't have to be done in this PR as this already an issue on the existing code, but maybe something to consider in the future.
Reworked and enhanced the Transformations attachment page.
Approach
settings-pages.phpapproach for adding the additional elements to the asset edit page.text_overlayandimage_overlaycolumns to the dbwp_cloudinary_relationshipstable. There are two main reasons behind that decision:transformation-- this is actually used on the front-end, which is built through the other JSON data.QA notes
During testing, consider image and video types.
This PR includes a DB upgrade, which happens on plugin install and checks the current and the previous Cloudinary versions.
wp_cloudinary_relationshipstable you should have thetext_overlayandimage_overlaycolumns:When those tables are available, go to the Media Library and add effects to an asset using that column:
By default, those icons should be empty in the Media Library.
Try different variations using the edit panels and ensure the preview works. If an invalid transformation is added to the free text, an alert will appear.
When using different effects, they should be reflected here:
Test the Clear buttons and ensure they remove the added text/image.
When saved effects, this message should appear for a few seconds.
When we apply effects, the relevant icons should be highlighted (example):
Test the front-end with assets that have effects and ensure the effects appear.
Update assets with new effects and ensure they are reflected on the front-end.
Test if all transformations appear in the Rest API as well. Example:
wp-json/wp/v2/media/4176Test the front-end with/without lazy-load enabled.
Ensure the Cloudinary Status shows all effects and the Edit Effects text link: