Problem with the images within the content
Description
A user reported that he can only get the featured image to come across and not the images within the article.
I tested, and indeed, the images within the article are not parsed, maybe because they're included in the
A strange thing that happened is that I didn't get the same featured image as him.
On SimplePie, they are rendered as expected: https://simplepie.org/demo/?feed=https%3A%2F%2Fwesternweekender.com.au%2Fcategory%2Ftravel%2Ffeed%2F
Reference: https://secure.helpscout.net/conversation/2419215275/392637?folderId=212385
Step-by-step reproduction instructions
- Go to Feedzy > Import
- Create a new import with this feed: https://westernweekender.com.au/category/travel/feed/
- Use map content to insert a featured image
Screenshots, screen recording, code snippet or Help Scout ticket
His website:
My website:
Environment info
No response
Is the issue you are reporting a regression
No
@AndreeaCristinaRadacina, have you tried with define( 'FEEDZY_ALLOW_UNSAFE_HTML', true ); ?
Doc - https://docs.themeisle.com/article/1154-how-to-use-feed-to-post-feature-in-feedzy#strip-tags
Thank you, @vytisbulkevicius! Now, the images are imported. However, the featured image is still the author's image actually. Do you know why something like this occurs? - https://root.stefancoti.com/escape-the-city-and-get-back-to-nature-at-pittwater-eco-yha/
@girishpanchal30, do you know why we're taking the author image as featured image from this feed? Based on the structure of items that author image is the last one and there are other images in the content before so I'm not sure what's the logic that we have so the last image is picked (author image).
Hey @vytisbulkevicius @AndreeaCristinaRadacina,
There is no other logic applied, we have fetched the first image from the content and set it to a thumbnail.
The mentioned feed returns the author's image in the first index, so there is an issue with the feed. Ref: https://tinyurl.com/ym8z7kbb
We can change the image via code snippets. Add the below code to your active theme functions.php file.
add_filter(
'feedzy_retrieve_image',
function ( $thumbnail, $item ) {
$string = $item->get_content();
$img = html_entity_decode( $string, ENT_QUOTES, 'UTF-8' );
$pattern = '/<img[^>]+\>/i';
preg_match_all( $pattern, $img, $matches );
$image = null;
if ( isset( $matches[0] ) ) {
$matches = reset( $matches );
$image = $matches[1];
$pattern = '/< *img[^>]*src *= *["\']?([^"\']*)/';
preg_match( $pattern, $image, $link );
if ( ! empty( $link ) && isset( $link[1] ) ) {
$thumbnail = $link[1];
}
}
return $thumbnail;
},
99,
2
);
Thanks
@AndreeaCristinaRadacina Can you check if the issue is fixed for you? Using the fixing code i still get author images as featured images for some items
@irinelenache, in my case, some images are broken (I think is because I disabled Optimole); the featured image is correct for others.
@girishpanchal30 @AndreeaCristinaRadacina I checked again and it's fine for me now 👍
Added this to our docs - https://docs.themeisle.com/article/942-in-feedzy-how-do-i#change-featured-image