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

[MIM-1933] Mim 1933 alt text employee #2839

Merged
merged 5 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main/resources/lib/types/partTypes/employee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface EmployeeProps {
pressPicturesDescrPhrase: string
pressPictureLabelPhrase: string
imagePhrase: string
pressImageAltText?: string
}

export interface Project {
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/site/parts/employee/employee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { type Content, get as getContentByKey } from '/lib/xp/content'
import { localize } from '/lib/xp/i18n'
import { getContent, pageUrl, attachmentUrl } from '/lib/xp/portal'
import { render } from '/lib/enonic/react4xp'
import { imageUrl } from '/lib/ssb/utils/imageUtils'
import { getImageAlt, imageUrl } from '/lib/ssb/utils/imageUtils'

import { renderError } from '/lib/ssb/error/error'
import * as util from '/lib/util'
Expand Down Expand Up @@ -31,6 +31,7 @@ function renderPart(req: XP.Request) {
const projects: Array<Project> = projectIds && projectIds.length > 0 ? parseProject(projectIds) : []
const profileImageIds: Array<string> = page.data.profileImages ? util.data.forceArray(page.data.profileImages) : []

const pressImageAltText = profileImageIds.length ? getImageAlt(profileImageIds[0]) : ''
const profileImages: Array<string> | void[] = profileImageIds
? profileImageIds.map((image: string) => {
return imageUrl({
Expand Down Expand Up @@ -156,6 +157,7 @@ function renderPart(req: XP.Request) {
pressPicturesDescrPhrase,
pressPictureLabelPhrase,
imagePhrase,
pressImageAltText,
}

return render('site/parts/employee/employee', props, req)
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/site/parts/employee/employee.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const Employee = (props: EmployeeProps) => {
pressPicturesDescrPhrase,
pressPictureLabelPhrase,
imagePhrase,
pressImageAltText,
} = props

const calculateCvSize = (bytes: number) => {
Expand Down Expand Up @@ -90,7 +91,7 @@ const Employee = (props: EmployeeProps) => {
<div className='employee-head col-12'>
{profileImages.length != 0 ? (
<div className='employee-image'>
<img alt='' src={props.profileImages[0]} aria-hidden='true' />
<img alt={pressImageAltText ?? ''} src={props.profileImages[0]} />
</div>
) : null}
{profileImages.length != 0 ? (
Expand Down
Loading