Skip to content
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

Image Optimization: Bulk Image Optimization #35

Open
wants to merge 7 commits into
base: enhance/PRESS7-76-lazy-load-images
Choose a base branch
from

Conversation

arunshenoy99
Copy link
Member

Proposed changes

Type of Change

Production

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Dependency update
  • Refactoring / housekeeping (changes to files not directly related to functionality)

Development

  • Tests
  • Dependency update
  • Environment update / refactoring
  • Documentation Update

Video

Checklist

  • I have read the CONTRIBUTING doc
  • I have viewed my change in a web-browser
  • Linting and tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments


const modalTitle = document.createElement( 'h2' );
modalTitle.id = 'nfd-modal-title';
modalTitle.textContent = 'Optimizing Images...';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔢 Localize text please.


const currentFileName = document.createElement( 'p' );
currentFileName.id = 'nfd-current-file';
currentFileName.textContent = 'Preparing files...';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔢 Localize text please.

@@ -83,6 +84,11 @@ private function register_settings() {
),
),
),
'bulk_optimization' => array(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move this option above lazy loading to have it be next to the other optimization ones?

try {
for ( let i = 0; i < selectedItems.length; i++ ) {
if ( cancelRequested ) {
modalTitle.textContent = 'Optimization Canceled';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Localize text

}

const { id: mediaId, name: fileName } = selectedItems[ i ];
currentFileName.textContent = `Optimizing: ${ fileName }`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Localize string

}

if ( ! cancelRequested ) {
modalTitle.textContent = 'Optimization Complete!';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Localize string

bulkOptimizeButton.id = bulkOptimizeButtonId;
bulkOptimizeButton.className =
'button media-button button-large button-primary';
bulkOptimizeButton.textContent = 'Optimize';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Localize string

setTimeout( closeModal, 2000 );
}
} catch ( error ) {
modalTitle.textContent = 'An error occurred.';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Localize string

document.querySelectorAll( '.attachment.selected' )
).map( ( attachment ) => ( {
id: attachment.getAttribute( 'data-id' ),
name: getFileName( attachment ),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems filename is always the same if we have more than one image selected because in getFileName function on 134 line where the file name is get by the .media-frame-content .filename that only provide the current selected file, so in case of more selected we only get the last seletec element file name.

Maybe we could change the line like this

Suggested change
name: getFileName( attachment ),
name: attachment.getAttribute( 'aria-label' ),

and then remove the getFileName function on line 133

@geckod22
Copy link
Contributor

About the bulk operation in media gallery I was also thinking this:
with multiple selected files at the end of the process if some of the images gave an error, the user really will never konw as the modal of course will update with the information of the following file and at the end will set as Operation complete and then will close. Should we maybe add a little banner like the result of the process (only in case with multiple selection). IT is just an idea, what do you think? maybe we don't want to give this feedback.

@arunshenoy99 arunshenoy99 changed the title Bulk Image Optimization Image Optimization: Bulk Image Optimization Dec 19, 2024
@arunshenoy99 arunshenoy99 added the enhancement New feature or request label Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants