add_attachment.php
1 month ago
admin_head.php
1 month ago
admin_init.php
1 month ago
admin_menu.php
1 month ago
admin_notices.php
1 month ago
attachment_updated.php
1 month ago
delete_post.php
1 month ago
pmxi_after_xml_import.php
1 month ago
pmxi_before_xml_import.php
1 month ago
pmxi_extend_options_custom_fields.php
1 month ago
wp_ajax_auto_detect_cf.php
1 month ago
wp_ajax_auto_detect_sf.php
1 month ago
wp_ajax_delete_import.php
1 month ago
wp_ajax_dismiss_notifications.php
1 month ago
wp_ajax_import_failed.php
1 month ago
wp_ajax_test_images.php
1 month ago
wp_ajax_wpai_dismiss_review_modal.php
1 month ago
wp_ajax_wpai_send_feedback.php
1 month ago
wpmu_new_blog.php
1 month ago
attachment_updated.php
29 lines
| 1 | <?php |
| 2 | if ( ! defined( 'ABSPATH' ) ) exit; |
| 3 | /** |
| 4 | * Fires once an existing attachment has been updated. |
| 5 | * |
| 6 | * @since 4.4.0 |
| 7 | * |
| 8 | * @param int $post_ID Post ID. |
| 9 | * @param WP_Post $post_after Post object following the update. |
| 10 | * @param WP_Post $post_before Post object before the update. |
| 11 | */ |
| 12 | function pmxi_attachment_updated($post_ID, $post_after, $post_before){ |
| 13 | // update image filename in pmxi_images table |
| 14 | if (wp_attachment_is_image($post_ID)){ |
| 15 | $imageRecord = new PMXI_Image_Record(); |
| 16 | $imageRecord->getBy(array( |
| 17 | 'attachment_id' => $post_ID |
| 18 | )); |
| 19 | if (!$imageRecord->isEmpty()){ |
| 20 | $image_name = basename(wp_get_attachment_url( $post_ID )); |
| 21 | // Do not update filename for scaled images. |
| 22 | if (strpos($image_name, '-scaled.') === FALSE) { |
| 23 | $imageRecord->set(array( |
| 24 | 'image_filename' => $image_name |
| 25 | ))->update(); |
| 26 | } |
| 27 | } |
| 28 | } |
| 29 | } |