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

[SEO] add alt to preload images for SEO crawlers #1195

Merged
merged 1 commit into from
Mar 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions packages/gallery/src/components/item/imageItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ class ImageItem extends React.Component {

const image = () => {
const imagesComponents = [];
const altText = typeof alt === 'string' ? alt : 'untitled image';
const blockDownloadStyles =
utils.isMobile() && this.props.options[optionsMap.behaviourParams.gallery.blockContextMenu]
? {
Expand Down Expand Up @@ -146,7 +147,7 @@ class ImageItem extends React.Component {
case GALLERY_CONSTS[optionsMap.behaviourParams.item.content.loader].BLUR:
preload = (
<ImageRenderer
alt=""
alt={altText}
key={'image_preload_blur-' + id}
src={createUrl(GALLERY_CONSTS.urlSizes.RESIZED, GALLERY_CONSTS.urlTypes.LOW_RES)}
style={{
Expand All @@ -162,7 +163,7 @@ class ImageItem extends React.Component {
case GALLERY_CONSTS[optionsMap.behaviourParams.item.content.loader].MAIN_COLOR:
preload = (
<ImageRenderer
alt=""
alt={altText}
key={'image_preload_main_color-' + id}
src={createUrl(GALLERY_CONSTS.urlSizes.PIXEL, GALLERY_CONSTS.urlTypes.HIGH_RES)}
style={{
Expand Down Expand Up @@ -195,7 +196,7 @@ class ImageItem extends React.Component {
data-hook="gallery-item-image-img"
data-idx={idx}
src={src}
alt={typeof alt === 'string' ? alt : 'untitled image'}
alt={altText}
tabIndex="0"
onLoad={this.handleHighResImageLoad}
loading={this.props.isPrerenderMode ? 'lazy' : 'eager'}
Expand Down