Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with the images within the content #824

Closed
AndreeaCristinaRadacina opened this issue Nov 13, 2023 · 8 comments
Closed

Problem with the images within the content #824

AndreeaCristinaRadacina opened this issue Nov 13, 2023 · 8 comments
Assignees
Labels
bug This label could be used to identify issues that are caused by a defect in the product. customer report Indicates the request came from a customer. doc-needed This issue requires documentation updates or additions once it has been completed.

Comments

@AndreeaCristinaRadacina
Copy link

AndreeaCristinaRadacina commented Nov 13, 2023

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 AndreeaCristinaRadacina added the bug This label could be used to identify issues that are caused by a defect in the product. label Nov 13, 2023
@pirate-bot pirate-bot added the customer report Indicates the request came from a customer. label Nov 13, 2023
@vytisbulkevicius
Copy link
Contributor

@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

@AndreeaCristinaRadacina
Copy link
Author

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/

@vytisbulkevicius
Copy link
Contributor

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

@girishpanchal30
Copy link
Contributor

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 girishpanchal30 added the doc-needed This issue requires documentation updates or additions once it has been completed. label Nov 16, 2023
@irinelenache
Copy link

@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

@AndreeaCristinaRadacina
Copy link
Author

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

@irinelenache
Copy link

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

@vytisbulkevicius
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This label could be used to identify issues that are caused by a defect in the product. customer report Indicates the request came from a customer. doc-needed This issue requires documentation updates or additions once it has been completed.
Projects
None yet
Development

No branches or pull requests

5 participants