From f6c89d5b46f964c2fcb064890912c84c0e7f49b1 Mon Sep 17 00:00:00 2001 From: girishpanchal30 Date: Tue, 10 Dec 2024 14:27:43 +0530 Subject: [PATCH 1/3] Add image URL support --- includes/admin/feedzy-rss-feeds-import.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/includes/admin/feedzy-rss-feeds-import.php b/includes/admin/feedzy-rss-feeds-import.php index a4c21b84..17577081 100644 --- a/includes/admin/feedzy-rss-feeds-import.php +++ b/includes/admin/feedzy-rss-feeds-import.php @@ -1872,6 +1872,8 @@ function( $term ) { } else { $img_success = false; } + } elseif ( wp_http_validate_url( $import_featured_img ) ) { + $image_source_url = $import_featured_img; } // Fetch image from graby. From 911312f410be69305d920d438547ecb4d910cbc6 Mon Sep 17 00:00:00 2001 From: girishpanchal30 Date: Tue, 10 Dec 2024 18:10:33 +0530 Subject: [PATCH 2/3] Update help text --- includes/views/import-metabox-edit.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/views/import-metabox-edit.php b/includes/views/import-metabox-edit.php index 32e0ddaf..a367dc1c 100644 --- a/includes/views/import-metabox-edit.php +++ b/includes/views/import-metabox-edit.php @@ -551,7 +551,7 @@ class="form-control fz-textarea-tagify">
From 7a5937a1c1bb146ff87b79b7608c9d32e76d2f3c Mon Sep 17 00:00:00 2001 From: girishpanchal30 Date: Thu, 12 Dec 2024 18:18:43 +0530 Subject: [PATCH 3/3] fix: prevent duplicate downloads of fallback images --- includes/admin/feedzy-rss-feeds-import.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/includes/admin/feedzy-rss-feeds-import.php b/includes/admin/feedzy-rss-feeds-import.php index 17577081..7c274fc4 100644 --- a/includes/admin/feedzy-rss-feeds-import.php +++ b/includes/admin/feedzy-rss-feeds-import.php @@ -1742,6 +1742,7 @@ function ( $attr, $key ) { $image_source_url = ''; $img_success = true; $new_post_id = 0; + $img_title = $item['item_title']; $feed_img_tag = ! empty( $import_featured_img ) && is_string( $import_featured_img ) ? $import_featured_img : ''; // image tag @@ -1765,10 +1766,11 @@ function ( $attr, $key ) { } } else { $image_source_url = $feed_img_tag; + $img_title = pathinfo( basename( $image_source_url ), PATHINFO_FILENAME ); } if ( ! empty( $image_source_url ) ) { - $img_success = $this->try_save_featured_image( $image_source_url, 0, $item['item_title'], $import_errors, $import_info, $new_post ); + $img_success = $this->try_save_featured_image( $image_source_url, 0, $img_title, $import_errors, $import_info, $new_post ); $new_post_id = $img_success; } @@ -1850,8 +1852,9 @@ function( $term ) { do_action( 'feedzy_import_extra', $job, $item_obj, $new_post_id, $import_errors, $import_info ); if ( ! empty( $import_featured_img ) && 'attachment' !== $import_post_type ) { - $image_source_url = ''; - $img_success = true; + $image_source_url = ''; + $img_success = true; + $img_title = $item['item_title']; $feed_img_tag = false === strpos( $import_featured_img, '[[{"value":' ) ? $import_featured_img : '[#item_image]'; // Use feed default image when we are using chained actions. @@ -1874,6 +1877,7 @@ function( $term ) { } } elseif ( wp_http_validate_url( $import_featured_img ) ) { $image_source_url = $import_featured_img; + $img_title = pathinfo( basename( $image_source_url ), PATHINFO_FILENAME ); } // Fetch image from graby. @@ -1920,7 +1924,7 @@ function( $term ) { } } - if ( 'yes' === $import_item_img_url || ! $this->tryReuseExistingFeaturedImage( $img_success, $item['item_title'], $new_post_id ) ) { + if ( 'yes' === $import_item_img_url || ! $this->tryReuseExistingFeaturedImage( $img_success, $img_title, $new_post_id ) ) { // Run chained actions. $import_featured_img = rawurldecode( $import_featured_img ); $import_featured_img = trim( $import_featured_img ); @@ -1934,7 +1938,7 @@ function( $term ) { update_post_meta( $new_post_id, 'feedzy_item_external_url', $image_source_url ); } else { // if import_featured_img is a tag. - $img_success = $this->try_save_featured_image( $image_source_url, $new_post_id, $item['item_title'], $import_errors, $import_info ); + $img_success = $this->try_save_featured_image( $image_source_url, $new_post_id, $img_title, $import_errors, $import_info ); } } }