Copied to clipboard

Flag this post as spam?

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


  • pmourao 2 posts 21 karma points
    Feb 09, 2009 @ 01:23
    pmourao
    0

    Get Media Url by Name

    Hi,

    I'm trying to get a image from Media Library without success. I've tried every implementation i've seen in this forum but none help. I'm new with Umbraco, but i'm almost sure that the error is not in the code.
    I'm using version 4.

    I've went to Media Library, create a new record, type Image and set the name to img1
    Then created GetMedia.xslt as with the following code:

    [code]
    ]>
    <>
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxml="urn:schemas-microsoft-com:xslt"
    xmlns:umbraco.library="urn:umbraco.library"
    exclude-result-prefixes="msxml umbraco.library">








    [/code]

    Created a Macro GetMedia with Parameter Alias=imgAlias, Name=imgAlias and Type=text

    In my MasterPage template inserted the following code:
    [code][/code]

    I'm getting the error: [i]Error parsing XSLT System.Xml.Xsl.XslCompiledTransform
    Value was either too large or too small for an Int32.[/i]

    This happens because $currentPage/data [@alias=$imgAlias] does not return any value.

    If I replace that by the file id, it works.

    Can I use this macro in the MasterPage?
    Am I uploandig the image correctly?

    Can anyone help me?

    Thanks

  • bob baty-barr 1180 posts 1294 karma points MVP
    Feb 09, 2009 @ 05:34
    bob baty-barr
    1

    try this instead...
    getMedia is trying to get a media file based on teh Media nodeID...
    so instead of having a text field on your macro to type in teh media alias... change that to a media picker -- this will return a nodeID

    in you xslt, you are already setting a variable, based on teh macro parameter... so you getMedia statement will look something like this...

    [code]

    [/code]

    this is off the top of my head, so you may need to tweak some stuff... but mediaPicker is definitely going to be more flexible for you in the long run.

    hope that helps.

  • pmourao 2 posts 21 karma points
    Feb 09, 2009 @ 07:16
    pmourao
    1

    Hi, thank you for your reply.

    I'm trying to get the file using just the name, not the id. For what I've reading I the $currentPage/data [@alias=$imgAlias] should return the Id for the node.

    Thanks

  • wolfestone 89 posts 21 karma points
    Feb 13, 2009 @ 23:54
    wolfestone
    1

    I'm trying to do something similar, but I've found no info at all on $imgAlias.

    Is it possible to display an image in a macro or template, if you only have it's alias/name? (not the file name, and not the media ID)

    My guess would be that it's not possible, since umbraco lets you create multiple images with the same alias, even within the same folder.

    Please could anyone confirm/deny this?

    Thanks

  • davelane 29 posts 73 karma points
    Sep 22, 2009 @ 15:39
    davelane
    1

    Hey all,

    It works for me if I set the $ImgAlias to "propertyTypePicker" in the macro parameters... then i can choose what property to use

    regards,
    dave

Please Sign in or register to post replies

Write your reply to:

Draft