docbrown/app/javascript/articles/components/ArticleCoverImage.jsx
Ben Halpern ec7adf56fe
Allow admins to set cover image height configs (#19936)
* Initial basic work

* Bulk of related work, including find/replace on the inputs

* Adjust some tests

* Adjust some specs

* Fix a few more tests

* Clean up tests

* Adjust tests

* Test fiddle

* Adjust crop back to be a param

* Update tests

* Set proper defaults

* Fix some styling

* Adjust enrichment logic and tests

* Adjust form JS

* Update test snapshot

* Clean up formatting

* Fix spec name

* Adjust some css and defaults

* Adjust translation for image provider options

* Switch from fill to fill-down

* Proper fallback image

* Fix tests

* Update app/services/images/optimizer.rb

Co-authored-by: Mac Siri <mac@forem.com>

---------

Co-authored-by: Mac Siri <mac@forem.com>
2023-08-21 13:25:16 -04:00

33 lines
867 B
JavaScript

import { h } from 'preact';
import { articlePropTypes } from '../../common-prop-types';
export const ArticleCoverImage = ({ article }) => {
return (
<div
className="crayons-article__cover crayons-article__cover__image__feed"
style={{
aspectRatio: `auto 1000 / ${article.main_image_height}`,
}}
>
<a
href={article.path}
className="crayons-article__cover__image__feed crayons-story__cover__image"
title={article.title}
>
<img
className="crayons-article__cover__image__feed"
src={article.main_image}
width="1000"
height={article.main_image_height}
alt={article.title}
/>
</a>
</div>
);
};
ArticleCoverImage.propTypes = {
article: articlePropTypes.isRequired,
};
ArticleCoverImage.displayName = 'ArticleCoverImage';