|
|
 Rank: Aficionado
Joined: 8/4/2006 Posts: 106 Location: London
|
Is there anyway to utilise the Media picker property type in a template, so I can use its value for an image? It currently outputs a number, and I haven't found a way to turn this into its actual URL.
Thanks
|
|
Rank: Devotee
Joined: 8/2/2006 Posts: 47
|
Use this to convert it to a path.
<img src="{umbraco.library:NiceUrl(@id)}" />
|
|
Rank: Devotee
Joined: 8/2/2006 Posts: 47
|
{umbraco.library:NiceUrl(@id)}
Arg!!! We need to be able to post code here!
|
|
 Rank: Aficionado
Joined: 8/4/2006 Posts: 106 Location: London
|
Does this go inside the <?UMBRACO_GETITEM tag?
|
|
 Rank: Aficionado
Joined: 8/4/2006 Posts: 106 Location: London
|
<?UMBRACO_GETITEM tag
^^
|
|
 Rank: Aficionado
Joined: 8/4/2006 Posts: 106 Location: London
|
Start again. Does this go inside the <?UMBRACO_GETITEM tag
Surely the body of this text is htmlencoded, so < are replaced with & lt;
|
|
Rank: Aficionado
Joined: 7/19/2006 Posts: 165 Location: aalleren, Denmark
|
You can't use the media pickers' value directly in a template atm. You would have to use a xslt macro to parse the ID to an image url with getmedia(). Another option could be to use the upload field editor control instead of the mediapicker as it outputs the actually path of the uploaded image, but depends on what you planned to do with it ofcourse. Umbracian Personal blog: Objects.dk
|
|
 Rank: Aficionado
Joined: 8/4/2006 Posts: 106 Location: London
|
It's for a header image for each page. I want to re-use ones in the media library rather than having to upload each time.
|
|
 Rank: Addict
Joined: 7/19/2006 Posts: 777 Location: Leigh-on-Sea, Essex, UK
|
Create a macro with a similar XSLT as mine below. <a href="http://jfs.momo.co.uk/xslt/getimage.xslt">http://jfs.momo.co.uk/xslt/getimage.xslt</a> Then put the macro in the relevent place in the template. Hope this helps. Warren Warren Buckley an Umbraco MVP 08-09 & level 1 certified developer
|
|
 Rank: Administration
Joined: 7/25/2006 Posts: 415 Location: vipperoed, denmark
|
If it's design elements used in templates they seldom need updating capabilities. I usually put them outside Umbraco. This requires some ftp access of cause. best, Jesper webbureau jesper.com doing webdesign / development / umbraco implementations / 2007&2008 MVP
|
|
 Rank: Aficionado
Joined: 8/4/2006 Posts: 106 Location: London
|
I get:
System.Xml.Xsl.XsltException: Function 'umbraco.library:GetMedia()' has failed. ---> System.ArgumentException: Cannot widen from target type to primitive type.
With that XSL template. Am I missing something obvious?
|
|
Rank: Devotee
Joined: 7/25/2006 Posts: 35
|
Just write an xsl:if tag around the call of the GetMedia function like :
xsl:if test="$mediaID != ''" ... GetMedia ... /xsl:if
|
|
Rank: Enthusiast
Joined: 7/26/2006 Posts: 29
|
I'm sitting with a similar problem.
I created the macro and xslt file. From the xslt I only want the url and nothing else. In my case I'm using the url for the background in the template via CSS.
My xslt body contains only the part: {umbraco.library:GetMedia($currentPage/data [@alias = 'BackgroundImage'], 'false')/data [@alias = 'umbracoFile']}
The macro outputs the whole line instead of just executing the function and returning the url. I tried to change the xsl:output method to "text", but it does not help. I have to wrap some xml/html around the line to make it process it correctly.
Is there a way to avoid this? I only need the url and that's it.
|
|
Rank: Enthusiast
Joined: 7/26/2006 Posts: 29
|
BTW.... I added the BackGround property (as a media picker) to the document type in "Generic Properties".
|
|
Rank: Enthusiast
Joined: 7/26/2006 Posts: 29
|
I found out about getting the output just as the url.
But testing whether or not there is a background media id is bugging a bit.
xsl:if test="$mediaID != ''"
what is $mediaID ?
|
|
|
Guest |