...and does the site that it doesn't work on have a Media node with that ID? (just need to double-check ... its always the little things that catch us out!)
If the Media node does exist, try this crude bit of 'debugging'...
It will output the XML that is returned from GetMedia. If you could copy-n-paste that here ... or a screengrab is fine. We can see what the problem is.
I'm getting confused between your environments/websites. First the broken site returned a media ID of 1073, then in the HTML source the ID is 1069?
I'm still thinking that the media node doesn't exist on the problem website.
The syntax that you originally posted worked fine on your development website, so its not the code/syntax that's the problem - its that it can't find the media node with that ID?
I've just deleted all media, reinstalled and still Nowt !
So I now have all new Node IDs eg Node 1105 (looking at the back-office) shows it contains the image 'bigfootbanner.jpg' I can hard code the node and get the image, so it exists, also FTP'ind shows the Node and Image (for some reason I can't insert an image here now)
The path of the image (uploaded via the Media section) wouldn't contain the nodeId as the folder. That number is the database ID from the cmsPropertyData table - it does has caused some confusion with newcomers.
I'd say hardcode the URL to the image for this instance. I'm not sure what it could be - if the media node is there, and the template syntax is correct, then it should work - like it has on the other environments/websites. Bit strange, but difficult to resolve without seeing the back-office set-up.
As you can see from the 'working site. I want to change the banner image for each 'different' page. Was passing the 'headImage' parameter in the document type as a means of doing this. So I guess I'll have to hard code each banner image in each page - why does it work great on two Hosts and not the other gets me !
I've connected to the SQL dB using SQL Developer (on MAC) for the site that does not render the image using XSLT. Here is a 'snippet' of the cmsPropertyData table showing Node IDs and the images contained... If any issue, the 'duff' site was installed via PLESK (Storm Internet), while the funcitoning one(s) used a Web App Gallery Installer (SEEKDOTNET) and my Localhost(ed) account..
Most wonderful answer for the 4.5, concerning the inline xlst Lee Kelleher!
Been searching ages around google in order to find a proper answer for 4.5, as there don't seem to be much documentation on how to use the media picker without a macro.
Using XSLT to retrieve an image (Media Pciker etc)
Hi all, in a similar vein, I have been using this inline XSLT to retrieve and display an image
<umbraco:Item runat="server" field="headImage" xslt="concat('<img src="', umbraco.library:GetMedia({0},'true')/ data[@alias='umbracoFile'], '" />')" XsltDisableEscaping="true" />
headImage is a parameter set in the document type ie it's a Media Picker
For one of my development sites it works, for localhost it works, but on my other development site, it doesn't. Any thoughts?
Which version of Umbraco are you using?
If its v4.5.1+ then the XSLT syntax is wrong, try this:
If it's 4.5.0 ... then upgrade, as there was a bug in GetMedia in that version - which is fixed in v4.5.1!
Cheers, Lee.
Lee
Version 4.0.3
Lee, to be precise
umbraco v 4.0.4.2 (Assembly version: 1.0.3811.17115)
Hi Tim,
What happens if you just output the 'headImage' field? Is it the correct Media id?
Cheers, Lee.
Lee
The Node ID is outputed
On the 'working site' I get the image in the Node
...and does the site that it doesn't work on have a Media node with that ID? (just need to double-check ... its always the little things that catch us out!)
If the Media node does exist, try this crude bit of 'debugging'...
It will output the XML that is returned from GetMedia. If you could copy-n-paste that here ... or a screengrab is fine. We can see what the problem is.
Cheers, Lee.
Lee
Where 'should' the XML output (I not you are using X<P opening and closing tags
Lee
Ok, here is the grab of the site with no image rendering, followed by the site where the image is rendered
Now where image renders
Lee
Note that the Node IDs are and I expect to be different as the sites are on two differing hosts...
Hi Tim,
I'm getting confused between your environments/websites. First the broken site returned a media ID of 1073, then in the HTML source the ID is 1069?
I'm still thinking that the media node doesn't exist on the problem website.
The syntax that you originally posted worked fine on your development website, so its not the code/syntax that's the problem - its that it can't find the media node with that ID?
- Lee
I chose a different Page (the site - broken is www.risktecsolutions.co.uk), the site working is www.eyetronics.co.uk
Both are development sites...
This is the code from the site that doesn't render
<div id="divTitleLogo">
<a href="/home.aspx"><img src="/media/49/blackravLogo.jpg" alt="Black Raviloi Logo" /></a>
<umbraco:Item runat="server" field="headImage" xslt="concat('<img src="', umbraco.library:GetMedia({0},'true')/ data[@alias='umbracoFile'], '" />')" XsltDisableEscaping="true" />
<umbraco:Item runat="server" field="headImage" />
<xmp>
<umbraco:Item runat="server" field="headImage" xslt="concat('<img src="', umbraco.library:GetMedia({0}, 0), '" />')" XsltDisableEscaping="true" />
</xmp>
</div><!-- end of divTitleLogo -->
Code from site that does (without the 'extra' headImage bit. Could it be the nesting of the folders where the 'media' is?
<div id="divTitleLogo">
<a href="/home.aspx"><img src="/media/images/blackraviolilogo.jpg" alt="Black Raviloi Logo" /></a>
<umbraco:Item runat="server" field="headImage" xslt="concat('<img src="', umbraco.library:GetMedia({0},'true')/ data[@alias='umbracoFile'], '" />')" XsltDisableEscaping="true" />
<xmp>
<umbraco:Item runat="server" field="headImage" xslt="concat('<img src="', umbraco.library:GetMedia({0}, 0), '" />')" XsltDisableEscaping="true" />
</xmp>
</div><!-- end of divTitleLogo -->
Hi Tim,
I don't want to sound like a stuck record, but could you check if the media node for ID 1064 does exist on the risktecsolutions.co.uk site, please?
Go to the Media section in the Umbraco back-office and hover-over the media node - it should show the ID your browser's status bar.
Everything else in your template appears to be fine.
Thanks, Lee.
Lee
I can confirm that Node ID 1064 exists on the Host associated with risktecsolutions.co.uk, as do all the other nodes...
Could it be the way I uploaded the zip of the images???
Lee
I've just deleted all media, reinstalled and still Nowt !
So I now have all new Node IDs eg Node 1105 (looking at the back-office) shows it contains the image 'bigfootbanner.jpg' I can hard code the node and get the image, so it exists, also FTP'ind shows the Node and Image (for some reason I can't insert an image here now)
Tim
Lee
This might or might not help !
In the 'flaky' site, I have had to point to the exact URL to get the static image
ie <img src="/media/1129/blackravlogo.jpg" alt="Black Raviloi Logo" />
Where 1129 is the Node ID and an actual folder
On the 'fuctioning site' (not the jpg are different names - I made a mistake in uploading) I can hard code just using the 'images' folder
ie <img src="/media/images/blackraviolilogo.jpg" alt="Black Raviloi Logo" />
In both Back-Office set-ups I created a folder 'images' in the Media Content
Hi Tim,
The path of the image (uploaded via the Media section) wouldn't contain the nodeId as the folder. That number is the database ID from the cmsPropertyData table - it does has caused some confusion with newcomers.
I'd say hardcode the URL to the image for this instance. I'm not sure what it could be - if the media node is there, and the template syntax is correct, then it should work - like it has on the other environments/websites. Bit strange, but difficult to resolve without seeing the back-office set-up.
Cheers, Lee.
Lee
As you can see from the 'working site. I want to change the banner image for each 'different' page. Was passing the 'headImage' parameter in the document type as a means of doing this. So I guess I'll have to hard code each banner image in each page - why does it work great on two Hosts and not the other gets me !
Lee
I've connected to the SQL dB using SQL Developer (on MAC) for the site that does not render the image using XSLT. Here is a 'snippet' of the cmsPropertyData table showing Node IDs and the images contained... If any issue, the 'duff' site was installed via PLESK (Storm Internet), while the funcitoning one(s) used a Web App Gallery Installer (SEEKDOTNET) and my Localhost(ed) account..
Most wonderful answer for the 4.5, concerning the inline xlst Lee Kelleher!
Been searching ages around google in order to find a proper answer for 4.5, as there don't seem to be much documentation on how to use the media picker without a macro.
Good job! I'd highfive you if i could!
Best regards,
Thomas Egebrand Gram
Hi Thomas, you're welcome! A virtual high-5 works for me! :-D
Cheers, Lee.
is working on a reply...