Skip to content

Commit afe8f45

Browse files
author
Michiel Verkoijen
committed
Select similar images once for more compatibility with WPML Media plugin.
1 parent a0ed01d commit afe8f45

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/class-tiny-image.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,10 +345,14 @@ public static function get_optimization_statistics( $result = null ) {
345345
$wpdb->posts.ID,
346346
$wpdb->posts.post_title,
347347
$wpdb->postmeta.meta_value,
348+
wp_postmeta_file.meta_value AS unique_attachment_name,
348349
wp_postmeta_tiny.meta_value AS tiny_meta_value
349350
FROM $wpdb->posts
350351
LEFT JOIN $wpdb->postmeta
351352
ON $wpdb->posts.ID = $wpdb->postmeta.post_id
353+
LEFT JOIN $wpdb->postmeta AS wp_postmeta_file
354+
ON $wpdb->posts.ID = wp_postmeta_file.post_id
355+
AND wp_postmeta_file.meta_key = '_wp_attached_file'
352356
LEFT JOIN $wpdb->postmeta AS wp_postmeta_tiny
353357
ON $wpdb->posts.ID = wp_postmeta_tiny.post_id
354358
AND wp_postmeta_tiny.meta_key = '" . self::META_KEY . "'
@@ -358,6 +362,7 @@ public static function get_optimization_statistics( $result = null ) {
358362
$wpdb->posts.post_mime_type = 'image/png'
359363
)
360364
AND $wpdb->postmeta.meta_key = '_wp_attachment_metadata'
365+
GROUP BY unique_attachment_name
361366
ORDER BY ID DESC";
362367

363368
$result = $wpdb->get_results( $query, ARRAY_A );

0 commit comments

Comments
 (0)