feedzy-rss-feeds icon indicating copy to clipboard operation
feedzy-rss-feeds copied to clipboard

Problem with the images within the content

Open AndreeaCristinaRadacina opened this issue 2 years ago • 7 comments

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

tag. I tried both with [#item_content] and [#item_full_content].

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

  1. Go to Feedzy > Import
  2. Create a new import with this feed: https://westernweekender.com.au/category/travel/feed/
  3. Use map content to insert a featured image

Screenshots, screen recording, code snippet or Help Scout ticket

His website: image

My website: image

Environment info

No response

Is the issue you are reporting a regression

No

AndreeaCristinaRadacina avatar Nov 13 '23 12:11 AndreeaCristinaRadacina

@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

vytisbulkevicius avatar Nov 13 '23 14:11 vytisbulkevicius

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/

AndreeaCristinaRadacina avatar Nov 13 '23 14:11 AndreeaCristinaRadacina

@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).

vytisbulkevicius avatar Nov 15 '23 23:11 vytisbulkevicius

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

girishpanchal30 avatar Nov 16 '23 06:11 girishpanchal30

@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 avatar Nov 16 '23 11:11 irinelenache

@irinelenache, in my case, some images are broken (I think is because I disabled Optimole); the featured image is correct for others.

AndreeaCristinaRadacina avatar Nov 16 '23 14:11 AndreeaCristinaRadacina

@girishpanchal30 @AndreeaCristinaRadacina I checked again and it's fine for me now 👍

irinelenache avatar Nov 20 '23 13:11 irinelenache

Added this to our docs - https://docs.themeisle.com/article/942-in-feedzy-how-do-i#change-featured-image

vytisbulkevicius avatar Jul 10 '24 07:07 vytisbulkevicius