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

Updated support data: <picture> #419

Merged
merged 1 commit into from
Jul 29, 2024

Conversation

DCoder18
Copy link
Contributor

@DCoder18 DCoder18 commented Apr 15, 2024

The expected result is we see the appropriate placeholder images (large to small) according to the screen size. If this is not supported, we should see a placeholder image with the Default text on it.

In Apple Mail, there is an odd issue where the picture tag and its child elements gets stripped along with any sibling elements in certain use cases. I have included testi links below with some of the use cases.

I tried using img and <div>Text</div> together with picture. In this case, only the img tag is stripped. The picture and div tags remain and works as expected.

@hteumeuleu
Copy link
Owner

I'm very curious about this one! Could you elaborate what you mean by ”<picture> tag is stripped in some cases.”? Even when glancing at the results of your Testi.at tests, I can't see what's wrong in Apple Mail.

@DCoder18
Copy link
Contributor Author

I've just updated the PR description now. As you can see, the results are quite strange and inconsistent. I cannot pin point what is exactly causing this issue yet. I do agree, the note can be made more clear. Do you have any suggestions on how I can improve the note I added?

@hteumeuleu
Copy link
Owner

@DCoder18 Could you share the code from the first faulty test?

@DCoder18
Copy link
Contributor Author

Here you go. In this case, both the picture and img tags are stripped in Apple Mail.

<!DOCTYPE html>
<html>
	<head>
		<title>picture element</title>
	</head>
	<body>
		<h1>picture</h1>
		
		<h1><code>picture</code> with <code>img</code></h1>
		<picture>
			<source srcset="https://40daystemp3.testi.at/placeholder/600x600/F4F4F4/5a5a5a.png?text=Small" media="(max-width: 480px)" />
			<source srcset="https://40daystemp3.testi.at/placeholder/600x600/F4F4F4/5a5a5a.png?text=Medium" media="(max-width: 640px)" />
			<source srcset="https://40daystemp3.testi.at/placeholder/600x600/F4F4F4/5a5a5a.png?text=Large" media="(min-width: 641px)" />
			<img src="https://40daystemp3.testi.at/placeholder/600x600/F4F4F4/5a5a5a.png?text=Default" alt="" style="display:block; width:100%; height:auto;" />
		</picture>
		

		<img src="https://40daystemp3.testi.at/placeholder/600x600/F4F4F4/5a5a5a.png?text=Default" alt="" style="display:block; width:100%; height:auto;" />
	</body>
</html>

@hteumeuleu
Copy link
Owner

@DCoder18 Thank you! It looks like to make this email work properly, all that's needed is to add background to the body (<body style="background:#fff;">). I think this is one of those cases where the email client has some heuristics to determine whether it's an HTML newsletter or a text email sent as HTML.

There might also be a problem with your image host (https://40daystemp3.testi.at/). It looks like it doesn't allow CORS requests (see https://parcel.io/tools/cors-check). Maybe this is why it does not work. Overall, I think this is a specific problem to the specific combination of "simple email + cors issue" and not worth a downgrade of support. (But perhaps a note indicating that images blocked by CORS are not downloaded?)

@DCoder18
Copy link
Contributor Author

I tried using an image host that allows CORS (https://placehold.co/600x400?text=Large). I still see the previous issue. However, when I tried adding a background color to the body like you suggested, it works. So, maybe CORS is not the issue here, rather a heuristics case like you mentioned. Do you think that's worth mentioning as a note?

@hteumeuleu hteumeuleu merged commit 25c6255 into hteumeuleu:main Jul 29, 2024
4 checks passed
hteumeuleu added a commit that referenced this pull request Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants