fix(media): apply fill positioning classes to private image fallback
This commit is contained in:
@@ -26,12 +26,17 @@ export default function MediaImage({
|
|||||||
const altText = alt ?? media.alt_text ?? media.original_name ?? '';
|
const altText = alt ?? media.alt_text ?? media.original_name ?? '';
|
||||||
|
|
||||||
if (media.visibility !== 'public') {
|
if (media.visibility !== 'public') {
|
||||||
|
// En mode `fill`, next/image se positionne en absolute pour remplir le
|
||||||
|
// parent relatif. On reproduit ce comportement avec `<img>` natif pour que
|
||||||
|
// les classes utilitaires (object-cover, object-contain) s'appliquent à
|
||||||
|
// l'image privée comme à la publique.
|
||||||
|
const fillClass = fill ? 'absolute inset-0 w-full h-full' : '';
|
||||||
// eslint-disable-next-line @next/next/no-img-element
|
// eslint-disable-next-line @next/next/no-img-element
|
||||||
return (
|
return (
|
||||||
<img
|
<img
|
||||||
src={url}
|
src={url}
|
||||||
alt={altText}
|
alt={altText}
|
||||||
className={className}
|
className={[fillClass, className].filter(Boolean).join(' ')}
|
||||||
loading={priority ? 'eager' : 'lazy'}
|
loading={priority ? 'eager' : 'lazy'}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user