Skip to content

Commit

Permalink
Merge pull request #1020 from Codeinwp/fix/918
Browse files Browse the repository at this point in the history
Added image URL support
  • Loading branch information
selul authored Dec 12, 2024
2 parents 6ddbd5a + 40e6a89 commit 140653e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
16 changes: 11 additions & 5 deletions includes/admin/feedzy-rss-feeds-import.php
Original file line number Diff line number Diff line change
Expand Up @@ -1745,6 +1745,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
Expand All @@ -1768,10 +1769,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;
}

Expand Down Expand Up @@ -1853,8 +1855,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.

Expand All @@ -1875,6 +1878,9 @@ function( $term ) {
} else {
$img_success = false;
}
} 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.
Expand Down Expand Up @@ -1921,7 +1927,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 );
Expand All @@ -1935,7 +1941,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 );
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion includes/views/import-metabox-edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ class="form-control fz-textarea-tagify"><?php echo esc_html( feedzy_custom_tag_e
</div>
<div class="help-text">
<?php
esc_html_e( 'You can use the magic tags, or leave it empty.', 'feedzy-rss-feeds' );
esc_html_e( 'You can use the magic tags, URL, or leave it empty.', 'feedzy-rss-feeds' );
?>
</div>
</div>
Expand Down

0 comments on commit 140653e

Please sign in to comment.