Skip to content

Commit

Permalink
fix: random get fallback item
Browse files Browse the repository at this point in the history
  • Loading branch information
girishpanchal30 committed Dec 20, 2024
1 parent 56ace7d commit b2f289a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions includes/admin/feedzy-rss-feeds-import.php
Original file line number Diff line number Diff line change
Expand Up @@ -2054,10 +2054,12 @@ function( $term ) {
// Set default thumbnail image.
if ( ! $img_success && ! empty( $default_thumbnail ) ) {
if ( is_array( $default_thumbnail ) ) {
shuffle( $default_thumbnail );
$default_thumbnail = reset( $default_thumbnail );
$random_key = array_rand( $default_thumbnail );
$default_thumbnail_id = isset( $default_thumbnail[ $random_key ] ) ? $default_thumbnail[ $random_key ] : 0;
} else {
$default_thumbnail_id = $default_thumbnail;
}
$img_success = set_post_thumbnail( $new_post_id, $default_thumbnail );
$img_success = set_post_thumbnail( $new_post_id, $default_thumbnail_id );
}

if ( ! $img_success ) {
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 @@ -863,7 +863,7 @@ class="fz-switch-toggle" type="checkbox" value="yes"
<input type="hidden" name="feedzy_meta_data[default_thumbnail_id]" id="feed-post-default-thumbnail" value="<?php echo esc_attr( implode( ',', $default_thumbnail_id ) ); ?>">
</div>
<div class="help-text pt-8">
<?php esc_html_e( 'Helpful for setting a fallback image for feed items without an image. By default, the fallback image from the global settings will be used. If multiple fallback images are selected, one of them will be randomly assigned to each post without an image during the import process.', 'feedzy-rss-feeds' ); ?>
<?php esc_html_e( 'Helpful for setting a fallback image for feed items without an image. If multiple fallback images are selected, one of them will be randomly assigned to each post without an image during the import process.', 'feedzy-rss-feeds' ); ?>
</div>
</div>
</div>
Expand Down

0 comments on commit b2f289a

Please sign in to comment.