Copied to clipboard

Flag this post as spam?

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


  • TomLeads 20 posts 42 karma points
    Feb 01, 2011 @ 14:29
    TomLeads
    1

    Media Picker / image upload advice

    Hi.

    I am creating a website that allows the admin to create pages of houses that are for sale.

    Each page can have upto 6 images. Currently I have them as a 'upload' property type, one for each photo.

    Is a mediapicker a better option here? Only problem with the mediapicker is that I have been unable to get the full url path of the image. So use the 'upload' data type a lot easier

            <umbraco:Item field="photo1" insertTextBefore="&lt;img width=&quot;562&quot; height=&quot;345&quot; id=&quot;main&quot; alt=&quot;&quot;" insertTextAfter="/&gt;" runat="server"></umbraco:Item>

    To extend these images, I would ideally need to put a description with each image. Is this possible?

    Thanks

    Tom

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Feb 01, 2011 @ 15:42
    Tom Fulton
    3

    Hi Tom,

    If you are using the Upload dataype, the only way to get a description with each image would be to add text fields for each upload box, ie Picture 1 Description, Picture 1 Upload, etc etc.  Which wouldn't be hard but it might not be the "cleanest" way.

    If you use a Media Picker you could use the media node's name as your description (depending on how long/complex these "descriptions" are) - or, you could add a field to the Image media type (or create a custom one) with the additional inputs you need.  You could then use uComponents Multi Node Tree Picker to have one datatype to select all the images.  Even better, you might try Jeroen's new Digibiz Advanced Media Picker (DAMP) that will allow you to pick multiple images and also upload them from the datatype.  Both packages will allow you to limit the images to 6 and prevent you from having to make 6 fields.

    Another good idea would be to use the new Embedded Content package and add two fields, Image Description (text) and Image (media picker).

    Personally, I would probably use DAMP as it makes it easier for the end user by allowing them to upload images, create folders, etc right from their content.  My next choice would be Embedded Content but I'm not sure if that allows upload directly from the datatype (may or may not be a big deal).

    Anyway, there are loads of options, it's really about what works best for you and your editors.  In all 3 cases you'd use XSLT to render your output - if you get stuck just let us know!  Let us know how you get on or if any questions...

    Thanks,
    Tom

  • Len Dierickx 150 posts 92 karma points
    Feb 01, 2011 @ 16:07
    Len Dierickx
    0

    Hi Tom, 

    I have been using both upload fields and extended media types and it is better to use media items.

    The problem I had/have with the upload field is that some editors copy the page they created last week. Then delete the images and upload new images on the newly copied page. The result is that the image from the original page disappeared. Maybe this behavior has changed with 4.6, I am not sure about that. 

    There are some projects that address this problem: http://our.umbraco.org/projects/fix-cloned-upload-fields-bug

    You can extend media types or create new media types just like document types and I would recommend doing it this way and not use the upload fields. It might save you some headaches.

    Thx/L. 

  • TomLeads 20 posts 42 karma points
    Feb 03, 2011 @ 10:50
    TomLeads
    0

    Hi. Thanks for that.

    I was able to extend the media picker options so they have to give it a title and some brief information.

    How can I now call this information and get it displayed on screen? The property type is "photoX" and it has values like "title" and "info".

    Thanks

    Tom

  • Len Dierickx 150 posts 92 karma points
    Feb 03, 2011 @ 11:12
    Len Dierickx
    0

    Hi Tom,

    This should help. Untested code ahead...

    The number 12345 represents the ID of the media node.

    <ul>
    <xsl:for-each select="umbraco.library:GetMedia(12345,1)/node/data">
        <li>
            <xsl:value-of select="@alias"/>
            <xsl:value-of select="': '"/>
            <xsl:value-of select="."/>
        </li>
    </xsl:for-each>
    </ul>

     

    The result should give you a list of all the data nodes for the media item and the name of that alias attribute. This way it shows which attributes you have and what the value for these fields are.
    Len. 

  • TomLeads 20 posts 42 karma points
    Feb 03, 2011 @ 11:32
    TomLeads
    0

    Hi, thanks for that.

    I'll need to get the ID of the node dynamically though, for each current page?

    I finally got some code working:

    <xsl:if test="$currentPage/photo1 != ''">
      <img id="main" width="562" height="345" alt="" src="{umbraco.library:GetMedia($currentPage/photo1,0)/umbracoFile}" />
    </xsl:if>

    Can I get further information (Title, height, width, etc) to work with this one?

  • Len Dierickx 150 posts 92 karma points
    Feb 03, 2011 @ 11:43
    Len Dierickx
    0

    Yes, you can get some attributes from Umbraco:

    http://our.umbraco.org/wiki/reference/umbracolibrary/getmedia

    <xsl:variable name="media" select="umbraco.library:GetMedia($currentPage/data[@alias='bannerImage'], 0)/data" />

     
    <xsl:if test="$media">
           
    <xsl:variable name="url" select="$media [@alias = 'umbracoFile']" />
           
    <xsl:variable name="width" select="$media [@alias = 'umbracoWidth']" />
           
    <xsl:variable name="height" select="$media [@alias = 'umbracoHeight']" />
           
    <img src="{$url}" width="{$width}" height="{$height}" />
     
    </xsl:if>

    For your title attribute that would be 

    <xsl:value-of select="data[@alias = 'Title']"/>

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Feb 03, 2011 @ 12:02
    Jeroen Breuer
    0

    Hello,

    If you're using the Digibiz Advanced Media Picker you can find some examples on how to use it in this topic: http://our.umbraco.org/forum/using/ui-questions/16806-Best-way-to-implement-multiple-media-pickers?p=1#comment63368.

    Jeroen

Please Sign in or register to post replies

Write your reply to:

Draft