Skip to content

Commit

Permalink
Fix hero image padding.
Browse files Browse the repository at this point in the history
  • Loading branch information
bstopp committed Apr 16, 2024
1 parent 635f21c commit cd11c3a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions cigaradvisor/blocks/articleheader/articleheader.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ export default async function decorate(block) {
const picture = block.querySelector('picture');
decorateSeoPicture(picture, window.location.pathname.substring(window.location.pathname.lastIndexOf('/') + 1));
imageWrapper.append(picture);
const img = picture.querySelector('img');
const ratio = (parseInt(img.height, 10) / parseInt(img.width, 10)) * 100;
picture.style.paddingBottom = `${ratio}%`;
const articleInfo = document.createElement('div');
articleInfo.classList.add('article-info');
const categoryLink = block.querySelector('p.category').innerText;
Expand Down
2 changes: 1 addition & 1 deletion cigaradvisor/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
import { loadReturnToTop } from '../blocks/return-to-top/return-to-top.js';
import addLinkingData from './linking-data.js';

const LCP_BLOCKS = [];
const LCP_BLOCKS = ['hero', 'articleheader'];
const AUTHOR_INDEX_PATH = '/cigaradvisor/index/author-index.json';
const CATEGORY_INDEX_PATH = '/cigaradvisor/index/category-index.json';
const ARTICLE_INDEX_PATH = '/cigaradvisor/index/article-index.json';
Expand Down

0 comments on commit cd11c3a

Please sign in to comment.