I have this bit of inline xslt in one of my templates that gets an item from the media library via a media picker datatype in one of my document types, is there a good way to define a default media item? I'd like it to be setup so that if the user doesn't specifically pick an image from the library before publishing the page, it will just use an image that I've defined.
also - do you need the true() to get children on your getmedia call? If not, changing it to false will save apparently save quite a bit of db overhead.
Another option you can use is to add the property bannerImmage to your root node (usually the homepage) and on your homepage select the default image. Then modify your inline xslt to be recursive:
Both excellent options. I understand some good reasoning for both, I went with the second one for the following reason.
I have a main News & Events page, with several News / Events documents underneath them. I didn't want my client to have to manually select a new banner image everytime they created a new news item, the banner is there more for structure than for content specific to that news post. I also wanted them to be able to change the banner if they wanted to for a specific item.
Default media if none selected
I have this bit of inline xslt in one of my templates that gets an item from the media library via a media picker datatype in one of my document types, is there a good way to define a default media item? I'd like it to be setup so that if the user doesn't specifically pick an image from the library before publishing the page, it will just use an image that I've defined.
Thank you!
<umbraco:Item runat="server" field="bannerImage" xslt="concat('<img src="',umbraco.library:GetMedia({0}, true())/data[@alias='umbracoFile'], '" />')" xsltDisableEscaping="true"/>
You could put this into simple xslt macro instead of the inline xslt (which imo gets very ugly very quickly)
something like
also - do you need the true() to get children on your getmedia call? If not, changing it to false will save apparently save quite a bit of db overhead.
Dan
Amir,
Another option you can use is to add the property bannerImmage to your root node (usually the homepage) and on your homepage select the default image. Then modify your inline xslt to be recursive:
Cheers
Paul
Dan, Paul,
Both excellent options. I understand some good reasoning for both, I went with the second one for the following reason.
I have a main News & Events page, with several News / Events documents underneath them. I didn't want my client to have to manually select a new banner image everytime they created a new news item, the banner is there more for structure than for content specific to that news post. I also wanted them to be able to change the banner if they wanted to for a specific item.
Thanks to both!
Amir
is working on a reply...