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

How to use enhanced:img with multiple images/srcset #13275

Open
eltigerchino opened this issue Jan 6, 2025 Discussed in #12660 · 1 comment
Open

How to use enhanced:img with multiple images/srcset #13275

eltigerchino opened this issue Jan 6, 2025 Discussed in #12660 · 1 comment

Comments

@eltigerchino
Copy link
Member

Discussed in #12660

Originally posted by lrwagner September 7, 2024
Say I have something like this to render a hero img:

	<enhanced:img
		src="$lib/assets/imgs/hero.jpg"
		sizes="(min-width: 1920px) 1920px, 
                             (min-width: 1440px) 1440px, 
                             (min-width: 1024px) 1024px, 
                             (min-width: 768px) 768px, 
                             100vw"
		alt="Hero"
	/>

What if I wanted to show a different img on Mobile because I want a different crop or aspect ratio - or maybe even a completely different img? Passing additional images to srcset doesn't seem to work.

@elliott-with-the-longest-name-on-github
Copy link
Contributor

Also interested in this. I'm currently just doing:

	<enhanced:img
                 class="md:hidden"
		src="$lib/assets/imgs/hero.jpg"
		alt="Hero"
	/>
        <enhanced:img
                 class="hidden md:visible"
		src="$lib/assets/imgs/hero.jpg"
		alt="Hero"
	/>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants