How do I... Embed image depending on the description?

Table of contents
  1. 1. sample output

Good for when you just want to change a user's profile image without changing the markup/code.
You just use the image's description for filtering.

{{
var photoList = map.select(page.files, "string.contains($.value.description, 'photo')");
if (#photoList > 0) {
  var photoFile = map.values(photoList)[0];
  web.image(photoFile.uri, 187, 187, photoFile.description);
 }
else {
  web.html("no photo");
 }
}}

sample output

If you want to change the image to another(better) one.  Just attach it and change it's description to "profile photo"You also need to remove the same description to the previous image.

profile photo

Tag page
Viewing 1 of 1 comments: view all
It will fail if just 1 image has no description:
$.value.description will return null at least 1 time, that null will not be handled by string.contains(), an exception is fired instead.

Workaround: concat with void string
$.value.description..''
A proper bug report should be issued against string.contains() eventually. edited 16:25, 16 Mar 2009
Posted 16:24, 16 Mar 2009
Viewing 1 of 1 comments: view all
You must login to post a comment.