Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Peng 41 posts 62 karma points
    Jun 29, 2010 @ 02:16
    Peng
    0

    Upgrade to umbraco 4.5 but getMedia does not work well

    I had some issue after upgrading an umbraco 4.0.3 site to umbaco 4.5

    // 1431 is the image id

    <textarea>
       
    <xsl:copy-of select="umbraco.library:GetMedia(1431, 'false')" />
    </textarea>

    Return:

    <node id="1431" version="f27b61d4-889d-4ed4-878f-10e9de66fc3e" parentID="1429" level="3" writerID="0" nodeType="1032" template="0" sortOrder="1" createDate="2010-04-16T12:25:17" updateDate="2010-04-16T12:25:17" nodeName="james-duthie" urlName="james-duthie" writerName="Administrator" nodeTypeAlias="Image" path="-1,1138,1429,1431">

      <data alias="umbracoFile">/media/15565/james-duthie.jpg</data>

      <data alias="umbracoWidth">35</data>

      <data alias="umbracoHeight">34</data>

      <data alias="umbracoBytes">933</data>

      <data alias="umbracoExtension">jpg</data>

    </node>

    Here the structure of the node is same as the old version v4.0.3 and I am not sure if the new schema will work for it.

    Then I tried :

         <xsl:for-each select="umbraco.library:GetMedia(1431, 'false')">
             <xsl:variable name="theNode" select="."/>
              <xsl:variable name="picFile" select="./data[@alias='umbracoFile']"/>
              Node : <xsl:value-of select="$theNode"/>
              file name -- <xsl:value-of select="$picFile"/>
            </xsl:for-each>
    Return:

             Node : /media/15565/james-duthie.jpg3534933jpg

              file name -- <empty>

    I also tried:

    <xsl:for-each select="umbraco.library:GetMedia(1431, 'false')/Image">
             <xsl:variable name="theNode" select="."/>
              <xsl:variable name="picFile" select="./data[@alias='umbracoFile']"/>
             Node : <xsl:value-of select="$theNode"/>
             file name -- <xsl:value-of select="$picFile"/>
            </xsl:for-each>

    Return: <empty/nothing>

    From: http://our.umbraco.org/forum/core/41-feedback/10128-umbracoFile-property-returns-empty?p=0#comment37120

    I tried this one:

    <img src="{umbraco.library:GetMedia(1431, 'false')/Image/umbracoFile}"/>

    But returned nothing.

     

    Thanks in advance.

  • Peng 41 posts 62 karma points
    Jun 29, 2010 @ 02:40
    Peng
    0

    Just now I created a image in umbraco 4.5 (from crach) and the node's content xml is stored in different structure in database compared with the one in umbraco v4.0.3 (see the previous post)

     <Image id="1117" version="cbfbf7b0-b3a7-498b-b68f-7714694ae7f0" parentID="-1" level="1" writerID="0" nodeType="1032" template="0" sortOrder="62" createDate="2010-06-29T10:34:30" updateDate="2010-06-29T10:34:31" nodeName="test" urlName="test" writerName="Administrator" nodeTypeAlias="Image" path="-1,1117">

    <umbracoFile>/media/471/72 and 84.png<umbracoFile>

     <umbracoWidth>1156 <umbracoWidth>

    <umbracoHeight>594 <umbracoHeight>

    <umbracoBytes>76447 <umbracoBytes>

    <umbracoExtension>png <umbracoExtension>  

    I am not sure if the getMedia in umbarco 4.5 works in different structures of node content xml.

     Thanks in advance!

     

     

     

     

  • Peng 41 posts 62 karma points
    Jun 29, 2010 @ 03:47
    Peng
    0

    I also tried to resave the media item and create new media itme but no luck.

  • Tom Madden 223 posts 313 karma points MVP c-trib
    Jun 29, 2010 @ 08:48
    Tom Madden
    0

    If you look at the XML, you will see that the node has a nodeTypeAlias of Image. The synatx to use in Umbraco 4.5 to retreive content from a specific nodeTypeAlias is to use the alias in the path as in /Image.

    The syntax to retreive the file path, width, height etc in 4.5 is therefore be:

    umbraco.library:GetMedia(1431, 'false')/Image/umbracoFile

    umbraco.library:GetMedia(1431, 'false')/Image/umbracoWidth

    etc

    Thanks to Lee Messenger for clarifying this during CodeGarden

    HTH
    Tom

  • Peng 41 posts 62 karma points
    Jun 29, 2010 @ 09:01
    Peng
    0

    Hi quixltd,

    Thanks! Yeah, you are right. But after upgrading an umbraco 4.0.3 site to umbraco 4.5, the media item's nodeContentXml is still follow the old xml schema. (Please check the first post in the thread).

    Regards,

    Peng

     

  • Peng 41 posts 62 karma points
    Jun 30, 2010 @ 10:34
    Peng
    0

    Now I found that I need to  <UseLegacyXmlSchema>false</UseLegacyXmlSchema> in umbracoSettings.config.

    After publishing the whole site, I got the content nodes stored in database with new schema.

    However the media items have to be manually saved up again.

     

     

  • Ismail Mayat 4511 posts 10056 karma points MVP 2x admin c-trib
    Nov 22, 2010 @ 12:15
    Ismail Mayat
    0

    Guys,

    I am also having this issue, is there a quick way to regenerate the media xml without having to manually resave each media item?  I want to use the new schema so setting legacy to true is not an option.

    Regards

    Ismail

     

  • Tommy Poulsen 514 posts 708 karma points
    Nov 22, 2010 @ 14:03
    Tommy Poulsen
    2

    You can do a publish of all items (including media) using this:

    /umbraco/dialogs/republish.aspx?xml=true

    >Tommy

     

  • Ismail Mayat 4511 posts 10056 karma points MVP 2x admin c-trib
    Nov 22, 2010 @ 14:41
    Ismail Mayat
    0

    Tommy,

    I already put together a dashboard control that loops through all media items and calls save method that fixed the issue.  Didnt know about the repbublish.aspx on media i thought it only did content.

    Regards

    Ismail

  • Dan Diplo 1490 posts 5809 karma points MVP 4x c-trib
    Nov 22, 2010 @ 18:29
    Dan Diplo
    0

    Thanks, Tommy, the republish.aspx?xml=true did the trick for me. This should be added to the upgrade Wiki!

  • Tommy Poulsen 514 posts 708 karma points
    Nov 22, 2010 @ 19:15
  • Tommy Poulsen 514 posts 708 karma points
    Nov 22, 2010 @ 20:05
    Tommy Poulsen
    0
Please Sign in or register to post replies

Write your reply to:

Draft