getPreviewImage (type, identifier) { const containers = RenderDataStore.getAllContainers(); if (isEmpty(containers)) return ''; if (type === 'TextField') { return URL_PARTIAL + containers.textFields[identifier].previewImage } else if (type === 'YouTubeLink') { let videoId = containers.youTubeLinks[identifier].videoId if (videoId) { return `https://img.youtube.com/vi/${ videoId }/hqdefault.jpg`; } return ''; } else if (type === 'TextBox') { return URL_PARTIAL + containers.textBoxes[identifier].previewImage } else if (type === 'DropDown') { let value = containers.dropDowns[identifier].value; if (value === undefined) { value = containers.dropDowns[identifier].default; } for (var i = containers.dropDowns[identifier].options.length - 1; i >= 0; i--) { if (containers.dropDowns[identifier].options[i].value === value) { return URL_PARTIAL + containers.dropDowns[identifier].options[i].previewImage; } } } return this.state.image; }
captionedImages.map( (capImage, i) => { let capFields = forceArray(capImage.Captions.CaptionField); if (isEmpty(capFields)) { mainImageData.push({id: i, file: capImage.Filename}); } else { mainImageData.push({id: i, file: capImage.Filename, captionsAndDropDowns: capFields.map(field => { return {value: field.Value, label: field.Label}; }) }); } });
function convertImageTemplatePartsToReactData (givenXmlObj) { let nameValuePairs = getNameValuePairsForMainCaptionFields(givenXmlObj); let imageContainerArray = extractAllImageContainers(givenXmlObj); if (isNotEmpty(imageContainerArray)) { imageContainerArray.map(imageContainerObj => { nameValuePairs.push(imageContainerObj); }) } if (isEmpty(nameValuePairs)) { return []; } else { return nameValuePairs; } }