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

  • 相关阅读:
    HA分布式集群二hive配置
    win下写任务提交给集群
    win10下将spark的程序提交给远程集群中运行
    Scala快学笔记(三)
    Scala快学笔记(二)
    Scala快学笔记(一)
    统计学习方法 三 kNN
    统计学习方法 二 感知机
    fluent python(一)
    Codewar (1)
  • 原文地址:https://www.cnblogs.com/czy/p/2590471.html
Copyright © 2011-2022 走看看