Copied to clipboard

Flag this post as spam?

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


  • Dan 1250 posts 3747 karma points admin c-trib
    Jan 11, 2010 @ 17:34
    Dan
    0

    Media type either flash file or image file

    Hi,

    A client wants the ability to choose either flash files or images via their media picker field, so I need a way of checking that the item is a .swf first (and presenting it in the appropriate HTML if so) or else returning the image in an <img> tag.

    Is the best way to code this in a macro, or can it be done neatly in the template?

    Thanks all

  • dandrayne 1138 posts 2262 karma points
    Jan 11, 2010 @ 17:48
    dandrayne
    1

    You can check

    umbracoExtension

    For the filetype, e.g.

    umbraco.library:GetMedia($currentPage/data [@alias='myField'], false)/data [@alias='umbracoExtension']

    Hope this starts you in the right direction

    Dan

  • Dan 1250 posts 3747 karma points admin c-trib
    Jan 11, 2010 @ 23:26
    Dan
    0

    Thanks Dan - for the record the following code seems to work (although I've no doubt it could be cleaner/better)

    <xsl:template match="/">
    <xsl:variable name="mediaId" select="/macro/mediaId" />
    <xsl:if test="$mediaId &gt; 0">
    <xsl:variable name="mediaNode" select="umbraco.library:GetMedia($mediaId, 0)" />
    <xsl:choose>
    <xsl:when test="umbraco.library:GetMedia($currentPage/data [@alias='bannerGraphic'], false)/data [@alias='umbracoExtension'] != 'swf'">
    <img src="{$mediaNode/data[@alias='umbracoFile']}" alt="" title="" />
    </xsl:when>
    <xsl:otherwise>
    <object width="957" height="156">
    <param name="movie" value="{$mediaNode/data[@alias='umbracoFile']}" />
    <embed src="{$mediaNode/data[@alias='umbracoFile']}" width="957" height="156"></embed>
    </object>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:if>
    </xsl:template>
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies