zoukankan      html  css  js  c++  java
  • Umbraco GetMediaComplete example CQ

    Supported by Nova Outsourcing

    Many Umbraco developers will run into the situation to get all the attributes returned by the GetMedia method. Here we go with a complete example to get all attributes returned by GetMedia.

    Attributes Table

    umbracoFile return the virtual path of the file which can be accessed from the url.
    umbracoWidth return the image width if the file is an image
    umbracoHeight return the height if the file is an image
    umbracoBytes return the file size
    umbracoExtension return the file extension

    Sample code

    The sample code below assume that you have a Media Picker type field named thumbnail. It will show the image on the page. If the image is not existing, the space of the image will not be rendered. The code below focuses on GetMedia and using attributes returned by GetMedia.

    <xsl:variable name="mediaId" select="thumbnail"/>
                <xsl:variable name="media" select="umbraco.library:GetMedia($mediaId, 0)" />
                <xsl:if test="$media">
                  <img src="{$media/umbracoFile}" width="{$media/umbracoWidth}" height="{$media/umbracoHeight}" align="left" />
                </xsl:if>
    

    Note: The code above only applies to Umbraco 4.7 or later. I haven’t done experiment on 4.5 or earlier versions.

    I will be glad to answer any questions on the issue.

     

    Supported by Nova Outsourcing

  • 相关阅读:
    Fleury算法
    2012 MultiUniversity Training Contest 2
    高斯若尔当消元法(线性代数)
    hdu4307(最小割)
    hdu4305(生成树计数)
    hdu4318(最短路)
    hdu4309(网络流)
    hdu4313(生成树)
    生成树计数
    MYSQL 远程登录及常用命令
  • 原文地址:https://www.cnblogs.com/czy/p/2590471.html
Copyright © 2011-2022 走看看