Skip to content

Commit

Permalink
Enhancement: Log message for Skip Image button now specifies which …
Browse files Browse the repository at this point in the history
…image is skipped and links to the `Edit Media` page for that image.
  • Loading branch information
arunbasillal committed Apr 26, 2022
1 parent 211f9e5 commit dbc334a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
22 changes: 20 additions & 2 deletions admin/iaff_image-attributes-from-filename-do.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,30 @@ function iaff_bulk_updater_skip_image() {
$counter = get_option( 'iaff_bulk_updater_counter' );
$counter = intval ( $counter );

global $wpdb;
$image = $wpdb->get_row("SELECT ID, post_parent FROM {$wpdb->prefix}posts WHERE post_type='attachment' AND post_mime_type LIKE 'image%' ORDER BY post_date LIMIT 1 OFFSET {$counter}");

/**
* Die if no image.
* This happens if there are no more images to skip.
*/
if ( $image === NULL ) {
$response = array(
'message' => __( 'No more images to skip.', 'auto-image-attributes-from-filename-with-bulk-updater' ),
'remaining_images' => iaff_count_remaining_images( true ),
);
wp_send_json( $response );
}

// Extract the image url
$image_url = wp_get_attachment_url($image->ID);

// Increment counter and update it
$counter++;
update_option( 'iaff_bulk_updater_counter', $counter );

$response = array(
'message' => __( 'One image skipped.', 'auto-image-attributes-from-filename-with-bulk-updater' ),
'message' => __( 'Image skipped: ', 'auto-image-attributes-from-filename-with-bulk-updater' ) . '<a href="'. get_edit_post_link( $image->ID ) .'">'. $image_url .'</a>',
'remaining_images' => iaff_count_remaining_images( true ),
);
wp_send_json( $response );
Expand Down Expand Up @@ -445,7 +463,7 @@ function iaff_do_bulk_updater(iaff_test=false) {
};

$.post(ajaxurl, data, function (response) {
$('#bulk-updater-log').append('<p class="iaff-green"><span class="dashicons dashicons-yes"></span>' + response.message + '</p>');
$('#bulk-updater-log').append('<p class="iaff-red"><span class="dashicons dashicons-remove"></span> ' + response.message + '</p>');
$('#bulk-updater-log').append('<p>Number of Images Remaining: ' + response.remaining_images + '</p>');
$("#bulk-updater-log").animate({scrollTop:$("#bulk-updater-log")[0].scrollHeight - $("#bulk-updater-log").height()},200);
});
Expand Down
7 changes: 6 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,15 @@ I am glad to hear that! You can either [upgrade to pro](https://imageattributesp

== Changelog ==

= 3.1 =
* Date:
* Tested with WordPress 5.9.3.
* Enhancement: Log message for `Skip Image` button now specifies which image is skipped and links to the `Edit Media` page for that image.

= 3.1 =
* Date: 24.March.2022.
* Tested with WordPress 5.9.2.
* New Feature: Added 'Skip Image' button for the Bulk Updater. Useful during troubleshooting. [Read more.](https://imageattributespro.com/fix-bulk-updater-stuck-on-same-image/?utm_source=wordpress.org&utm_medium=changelog)
* New Feature: Added `Skip Image` button for the Bulk Updater. Useful during troubleshooting. [Read more.](https://imageattributespro.com/fix-bulk-updater-stuck-on-same-image/?utm_source=wordpress.org&utm_medium=changelog)
* Enhancement: Compatibility with Image Attributes Pro version 3.0. [Check what's new in 3.0.](https://imageattributespro.com/changelog/?utm_source=wordpress.org&utm_medium=changelog)

= 3.0 =
Expand Down

0 comments on commit dbc334a

Please sign in to comment.