Skip to content

Commit

Permalink
IBX-154: Allowed to define if the alternative text for image field is…
Browse files Browse the repository at this point in the history
… required (2.5) (#292)
  • Loading branch information
adamwojs authored Jun 25, 2021
1 parent 48f132c commit 2cebaea
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,18 @@ const prepareStruct = ({ parentInfo, config, languageCode }, data) => {
.then((response) => response.json())
.catch(() => window.eZ.helpers.notification.showErrorNotification('Cannot get content type by identifier'))
.then((response) => {
const fileValue = {
fileName: data.file.name,
data: data.fileReader.result.replace(/^.*;base64,/, ''),
};

if (data.file.type.startsWith('image/')) {
fileValue.alternativeText = data.file.name;
}

const fields = [
{ fieldDefinitionIdentifier: mapping.nameFieldIdentifier, fieldValue: data.file.name },
{
fieldDefinitionIdentifier: mapping.contentFieldIdentifier,
fieldValue: { fileName: data.file.name, data: data.fileReader.result.replace(/^.*;base64,/, '') },
},
{ fieldDefinitionIdentifier: mapping.contentFieldIdentifier, fieldValue: fileValue },
];

const struct = {
Expand Down

0 comments on commit 2cebaea

Please sign in to comment.