Browse Source

display kind 20 alt text

imwald
Silberengel 3 days ago
parent
commit
fb10548d61
  1. 1
      src/components/Image/index.tsx
  2. 11
      src/components/ImageGallery/index.tsx
  3. 11
      src/components/ImageWithLightbox/index.tsx

1
src/components/Image/index.tsx

@ -128,6 +128,7 @@ export default function Image({
<img <img
src={imageUrl} src={imageUrl}
alt={finalAlt} alt={finalAlt}
title={finalAlt || undefined}
decoding="async" decoding="async"
loading="lazy" loading="lazy"
draggable={false} draggable={false}

11
src/components/ImageGallery/index.tsx

@ -7,7 +7,9 @@ import { TImetaInfo } from '@/types'
import { ReactNode, useEffect, useMemo, useState } from 'react' import { ReactNode, useEffect, useMemo, useState } from 'react'
import { createPortal } from 'react-dom' import { createPortal } from 'react-dom'
import Lightbox from 'yet-another-react-lightbox' import Lightbox from 'yet-another-react-lightbox'
import Captions from 'yet-another-react-lightbox/plugins/captions'
import Zoom from 'yet-another-react-lightbox/plugins/zoom' import Zoom from 'yet-another-react-lightbox/plugins/zoom'
import 'yet-another-react-lightbox/plugins/captions.css'
import Image from '../Image' import Image from '../Image'
import ImageWithLightbox from '../ImageWithLightbox' import ImageWithLightbox from '../ImageWithLightbox'
@ -110,14 +112,15 @@ export default function ImageGallery({
<Lightbox <Lightbox
index={index} index={index}
slides={(() => { slides={(() => {
const slides = images.map(({ url, alt }) => ({ const slides = images.map(({ url, alt }) => ({
src: url, src: url,
alt: alt || url alt: alt || url,
title: alt || undefined
})) }))
logger.debug('[ImageGallery] Lightbox slides:', { index, slidesCount: slides.length, slides }) logger.debug('[ImageGallery] Lightbox slides:', { index, slidesCount: slides.length, slides })
return slides return slides
})()} })()}
plugins={[Zoom]} plugins={[Zoom, Captions]}
open={index >= 0} open={index >= 0}
close={() => setIndex(-1)} close={() => setIndex(-1)}
controller={{ controller={{

11
src/components/ImageWithLightbox/index.tsx

@ -7,7 +7,9 @@ import { useEffect, useMemo, useState } from 'react'
import { createPortal } from 'react-dom' import { createPortal } from 'react-dom'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import Lightbox from 'yet-another-react-lightbox' import Lightbox from 'yet-another-react-lightbox'
import Captions from 'yet-another-react-lightbox/plugins/captions'
import Zoom from 'yet-another-react-lightbox/plugins/zoom' import Zoom from 'yet-another-react-lightbox/plugins/zoom'
import 'yet-another-react-lightbox/plugins/captions.css'
import Image from '../Image' import Image from '../Image'
export default function ImageWithLightbox({ export default function ImageWithLightbox({
@ -73,11 +75,12 @@ export default function ImageWithLightbox({
<div onClick={(e) => e.stopPropagation()}> <div onClick={(e) => e.stopPropagation()}>
<Lightbox <Lightbox
index={index} index={index}
slides={[{ slides={[{
src: image.url, src: image.url,
alt: image.alt || image.url alt: image.alt || image.url,
title: image.alt || undefined
}]} }]}
plugins={[Zoom]} plugins={[Zoom, Captions]}
open={index >= 0} open={index >= 0}
close={() => setIndex(-1)} close={() => setIndex(-1)}
controller={{ controller={{

Loading…
Cancel
Save