Skip to content

Commit 140653e

Browse files
authored
Merge pull request #1020 from Codeinwp/fix/918
Added image URL support
2 parents 6ddbd5a + 40e6a89 commit 140653e

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

includes/admin/feedzy-rss-feeds-import.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1745,6 +1745,7 @@ function ( $attr, $key ) {
17451745
$image_source_url = '';
17461746
$img_success = true;
17471747
$new_post_id = 0;
1748+
$img_title = $item['item_title'];
17481749
$feed_img_tag = ! empty( $import_featured_img ) && is_string( $import_featured_img ) ? $import_featured_img : '';
17491750

17501751
// image tag
@@ -1768,10 +1769,11 @@ function ( $attr, $key ) {
17681769
}
17691770
} else {
17701771
$image_source_url = $feed_img_tag;
1772+
$img_title = pathinfo( basename( $image_source_url ), PATHINFO_FILENAME );
17711773
}
17721774

17731775
if ( ! empty( $image_source_url ) ) {
1774-
$img_success = $this->try_save_featured_image( $image_source_url, 0, $item['item_title'], $import_errors, $import_info, $new_post );
1776+
$img_success = $this->try_save_featured_image( $image_source_url, 0, $img_title, $import_errors, $import_info, $new_post );
17751777
$new_post_id = $img_success;
17761778
}
17771779

@@ -1853,8 +1855,9 @@ function( $term ) {
18531855
do_action( 'feedzy_import_extra', $job, $item_obj, $new_post_id, $import_errors, $import_info );
18541856

18551857
if ( ! empty( $import_featured_img ) && 'attachment' !== $import_post_type ) {
1856-
$image_source_url = '';
1857-
$img_success = true;
1858+
$image_source_url = '';
1859+
$img_success = true;
1860+
$img_title = $item['item_title'];
18581861

18591862
$feed_img_tag = false === strpos( $import_featured_img, '[[{"value":' ) ? $import_featured_img : '[#item_image]'; // Use feed default image when we are using chained actions.
18601863

@@ -1875,6 +1878,9 @@ function( $term ) {
18751878
} else {
18761879
$img_success = false;
18771880
}
1881+
} elseif ( wp_http_validate_url( $import_featured_img ) ) {
1882+
$image_source_url = $import_featured_img;
1883+
$img_title = pathinfo( basename( $image_source_url ), PATHINFO_FILENAME );
18781884
}
18791885

18801886
// Fetch image from graby.
@@ -1921,7 +1927,7 @@ function( $term ) {
19211927
}
19221928
}
19231929

1924-
if ( 'yes' === $import_item_img_url || ! $this->tryReuseExistingFeaturedImage( $img_success, $item['item_title'], $new_post_id ) ) {
1930+
if ( 'yes' === $import_item_img_url || ! $this->tryReuseExistingFeaturedImage( $img_success, $img_title, $new_post_id ) ) {
19251931
// Run chained actions.
19261932
$import_featured_img = rawurldecode( $import_featured_img );
19271933
$import_featured_img = trim( $import_featured_img );
@@ -1935,7 +1941,7 @@ function( $term ) {
19351941
update_post_meta( $new_post_id, 'feedzy_item_external_url', $image_source_url );
19361942
} else {
19371943
// if import_featured_img is a tag.
1938-
$img_success = $this->try_save_featured_image( $image_source_url, $new_post_id, $item['item_title'], $import_errors, $import_info );
1944+
$img_success = $this->try_save_featured_image( $image_source_url, $new_post_id, $img_title, $import_errors, $import_info );
19391945
}
19401946
}
19411947
}

includes/views/import-metabox-edit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ class="form-control fz-textarea-tagify"><?php echo esc_html( feedzy_custom_tag_e
551551
</div>
552552
<div class="help-text">
553553
<?php
554-
esc_html_e( 'You can use the magic tags, or leave it empty.', 'feedzy-rss-feeds' );
554+
esc_html_e( 'You can use the magic tags, URL, or leave it empty.', 'feedzy-rss-feeds' );
555555
?>
556556
</div>
557557
</div>

0 commit comments

Comments
 (0)