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

chore: better image breakpoint #195

Merged
merged 2 commits into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/lib-franklin.js
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ export async function loadBlocks(main) {
* @param {Array} [breakpoints] Breakpoints and corresponding params (eg. width)
* @returns {Element} The picture element
*/
export function createOptimizedPicture(src, alt = '', eager = false, breakpoints = [{ media: '(min-width: 400px)', width: '2000' }, { width: '750' }]) {
export function createOptimizedPicture(src, alt = '', eager = false, breakpoints = [{ media: '(min-width: 600px)', width: '2000' }, { width: '750' }]) {
const url = new URL(src, window.location.href);
const picture = document.createElement('picture');
const { pathname } = url;
Expand Down
4 changes: 2 additions & 2 deletions test/scripts/body.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div>
<p>
<picture>
<source media="(max-width: 400px)" srcset="./media_mock.png?width=750&amp;format=webply&amp;optimize=medium">
<source media="(max-width: 600px)" srcset="./media_mock.png?width=750&amp;format=webply&amp;optimize=medium">
<img src="/test/scripts/media_mock.png?width=2000&amp;format=webply&amp;optimize=medium" alt="" loading="eager">
</picture>
</p>
Expand All @@ -30,7 +30,7 @@ <h6 id="this-is-a-heading-6">This is a Heading 6</h6>
culpa qui officia deserunt mollit anim id est <a href="https://www.hlx.live/">laborum</a>.</p>
<p>
<picture>
<source media="(max-width: 400px)"
<source media="(max-width: 600px)"
srcset="/test/scripts/media_mock.png?width=750&amp;format=webply&amp;optimize=medium">
<img src="/test/scripts/media_mock.png?width=2000&amp;format=webply&amp;optimize=medium"
alt="" loading="eager">
Expand Down