Problem with getMedia in 3.0.5 ? Options
seb
Posted: Tuesday, May 13, 2008 1:48:16 PM

Rank: Devotee

Joined: 1/10/2008
Posts: 61
Location: London
Hi there,

I've got a new problem with this function, only with documents recently added (before the migration from 3.0.3 to 3.0.5).

The function seems to add some extra-information to the file name.
Example:

when I'm expecting something like '/media/20047/regionalmanager_app_april08.doc'

the function returns '/media/20047/regionalmanager_app_april08.docdoc275968'

and only on documents that have been uploaded to the media library before the upgrade.

Anybody else has mentionned a smiliar behaviour ?


Edit: I should have mentionned, I'm using the function in XSLT, with the Deep param set to true or false, no matter.

Code:

<a href="{umbraco.library:GetMedia(1365,0)}" target="_blank">Doc</a>


seb

http://www.be-k.net
seb
Posted: Tuesday, May 13, 2008 2:14:42 PM

Rank: Devotee

Joined: 1/10/2008
Posts: 61
Location: London
ok, I had a quick look at the source code; the function is running the following sql query:


select xml from cmsContentXml where nodeID=1365


which returns a node with 3 children:
Code:

<node id="1365" version="f428d7df-abc0-45f5-bf5e-6169fc5a1161" parentID="1364" level="3" writerID="0" nodeType="1033" template="0" sortOrder="1" createDate="2008-05-13T11:59:39" updateDate="2008-05-13T11:59:39" nodeName="Application form" urlName="applicationform" writerName="Administrator" nodeTypeAlias="File" path="-1,1247,1364,1365">
<data alias="umbracoFile">/media/20047/regionalmanager_app_april08.doc</data>
<data alias="umbracoExtension">doc</data>
<data alias="umbracoBytes">275968</data>
</node>



I tried to run the same sql query with an older document, "umbracoExtension" and "umbracoBytes" are not presents. So what's happening with my problem is that "umbracoExtension" and "umbracoBytes" are added to "umbracoFile".

It's like something goes wrong in the ToXml() method, I'm not sure what.

seb

http://www.be-k.net
mortenbock
Posted: Tuesday, May 13, 2008 2:20:02 PM

Rank: Addict

Joined: 7/19/2006
Posts: 733
Location: Århus, Denmark
Try this:
Code:

<a href="{umbraco.library:GetMedia(1365,0)/data [@alias = 'umbracoFile']}" target="_blank">Doc</a>


I'm looking for a new job

Morten Bock - Level 2 certified - MVP 2008/2009 - My danish blog with a few english posts

seb
Posted: Tuesday, May 13, 2008 2:26:48 PM

Rank: Devotee

Joined: 1/10/2008
Posts: 61
Location: London
Thanks, that works !

Probably this is not how it's meant to be though, I'll add a comment on codeplex.

thanks again for the tip,

seb

http://www.be-k.net
mortenbock
Posted: Tuesday, May 13, 2008 3:03:37 PM

Rank: Addict

Joined: 7/19/2006
Posts: 733
Location: Århus, Denmark
seb wrote:

Probably this is not how it's meant to be though, I'll add a comment on codeplex.


It think it is by design, and not a bug. The reason for the XML structure is that you might want to get some other details about the file, than just the file location. Also the structure follows the same schema as the regular node structure in umbraco, so it is consistent with the rest of the system.

I'm looking for a new job

Morten Bock - Level 2 certified - MVP 2008/2009 - My danish blog with a few english posts

hartvig
Posted: Wednesday, May 14, 2008 6:55:45 PM

Rank: Addict

Joined: 3/17/2008
Posts: 808
Location: Nyborg, Denmark
This is by design - it returns a full xpath navigator, so you have access to all the properties. As you're able to add an unlimited number of custom properties to a media item, it's nice to be able to access all of them.

When you get a weird string, it's simply because you're using the method in a wrong way and not like Morten describes.

Jeeeez, did I really start this :-)
Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.