Fallback for language depending pictures with missing content

hoebbel
Crownpeak employee
Crownpeak employee
1 0 916

If you are using language depending pictures, maybe you will have the problem, that an editor missed to put a picture within all the languages of the picture.

In this case you will get an error during generation (target for $CMS_REF()$ not found: media:"<UID>") and a broken picture link.

You can solve this problem by using the following code (this will create a fallback to the picture in the master language and create an appropriate warning)

<img src="

$CMS_IF(ref(pt_picture).target.getPicture(#global.language).getPictureMetaData(#global.project.getResolutionByName("ORIGINAL")).size > 0)$

$CMS_REF(pt_picture)$

$CMS_ELSE$

$CMS_REF(pt_picture,language:#global.project.masterLanguage)$

$CMS_VALUE(#global.logWarning("Picture " + ref(pt_picture).target.uid + " (ID:" + ref(pt_picture).target.id + ") has no content within the language " + #global.language.abbreviation))$

$CMS_END_IF$

"/>

If you want to create a link to another resolution then the original resolution, you still have to check the size of the picture in the ORIGINAL resolution for  the appropriate language!

Version history
Last update:
‎12-12-2011 03:58 AM
Updated by: