Copied to clipboard

Flag this post as spam?

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


  • Vijay 30 posts 47 karma points
    Sep 17, 2009 @ 23:59
    Vijay
    0

    Accessing images in the Media section in xsl without media picker.

    Here is my problem:

    I have a document type which has a text string, that has a comma separated list of all the images that need to be displayed on the page.

    I see those images in the "Media" section of Umbraco under a new folder I created.

    I dont have a media picker on the document type I created. 

    In xsl I am already parsing each image name from the comma separated string.  Now using this how do I set the "src" attribute on an image tag inside xsl, to display the image. Or in other words, how do I access the images in the Media section, based on the image name, when I dont have a media picker.

    Any help would be greatly appreciated. I did search this forum but couldnt find an answer.  Thanks in advance

  • Vijay 30 posts 47 karma points
    Sep 18, 2009 @ 00:16
    Vijay
    0

    this is the code i have in there and it doesnt work

    <xsl:if test="string-length($currentPage/ancestor-or-self::node/data [@alias='test.jpg']) &gt; 0">
      <img>
        <xsl:attribute name="src">
          <xsl:value-of select="umbraco.library:GetMedia($currentPage/ancestor-or-self::node/data [@alias='test.jpg'], 'false')/data [@alias = 'umbracoFile']"/>
        </xsl:attribute>
      </img>
    </xsl:if>   

  • Petr Snobelt 923 posts 1535 karma points
    Sep 18, 2009 @ 08:42
    Petr Snobelt
    0

    I'm not sure, but I think you have not alias type 'test.jpg' in your datatype.

  • Jannik Nilsson 38 posts 81 karma points
    Sep 18, 2009 @ 08:59
    Jannik Nilsson
    0

    Do you have a folder of images for each page?

  • Vijay 30 posts 47 karma points
    Sep 18, 2009 @ 16:07
    Vijay
    0

    Thank you guys for your replies.

    No I have one folder for all the images.  Basically we dump all the pictures in one folder.  On the page, we have a string that stores the comma separated list of all the images.  Now when I parse through each member in the list, I need to find and display that image on the page.

    I hope this makes sense.  Please let me know if it doesnt.

  • Vijay 30 posts 47 karma points
    Sep 21, 2009 @ 16:12
    Vijay
    0

    can anyone help me on this? we are running out of time and ideas. thanks

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Sep 21, 2009 @ 16:33
    Dirk De Grave
    0

    Hi Vijay,

    So you have a comma separated string stored as value for a document property (For example: "test.jpg,test-1.jpg"), and those images are all stored in a folder in the media section? It's a bit of a pain I guess, as from an image name, it's pretty hard to find the path. Even though images are stored in the same folder in the media section, the individual images (their filename) don't have a reference to the 'media section' folder in which they reside.

    test.jpg may be stored in folder /media/1234/test.jpg whereas test-1.jpg may be stored as /media/4567/test-1.jpg but there's nothing that ties those filenames to the folder you've created in the media section.

    As a quick workaround, I'd store the image node id's in your document property, split the values (as it's a comma separated value), use GetMedia() function to get the filename path based on the media node id.

    Other workaround would be to create a small xslt extension to 'search' for an image in the /media folder based on the image filename.

     

    Still, I'd like to hear why you're not using media picker or the tree multi picker. You may get out of sync if someone uploads a new version of an image which does not have the same filename.

     

    Cheers,

    /Dirk

  • Vijay 30 posts 47 karma points
    Sep 21, 2009 @ 17:14
    Vijay
    0

    Dirk, Thanks a bunch for replying.

    Here is the reason why we are not using a media picker/tree multi picker.  Maybe you can point out the flaw and show us the correct path.  We are displaying all images that come in an xml file, which we get from a different service.  As of now, we are importing that xml file into umbraco using one of the available packages.  I dont know how we could use a media picker to associate all these images, as the number of images vary.

    Also could you please tell us how to implement the second idea? i.e how do I create and xslt to search for an image in the media folder based on the file name?

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Sep 21, 2009 @ 21:24
    Dirk De Grave
    0

    Ok, that's a viable reason for not using media pickers? Are those images also transferred from source to your target dir in the /media folder? How is that handled?

    About implementing an xslt extension, here's an interesting read on how to build xslt extensions. In your case, you'd have to build a static function that accepts an string parameter (name of the pic file) and returns the complete path of the image.

     

    Let me know if still unclear.

     

    Hope this helps.

    Regards,

    /Dirk

     

  • Vijay 30 posts 47 karma points
    Sep 23, 2009 @ 21:12
    Vijay
    0

    Dirk,

      I guess I gave in and added a media picker to the master content page. This media picker points to the parent image folder(the one I created) in the media section.  This way I have access to all the media files in each of the child pages. Now after parsing through my comma separated list of image names, I choose the correct image and display it.

      Thanks again for everybody's help regarding this issue.

Please Sign in or register to post replies

Write your reply to:

Draft