Getting Image Path

sbarre5's Avatar

sbarre5

17 Feb, 2015 07:26 PM

I'm trying to get an image path but it doesn't seem to be working.

XML:

<system-data-structure>
    <page-element>
        <include-header>
            <value>Yes</value>
        </include-header>
        <content-type>Text (w/ Supporting Media)</content-type>
        <header>
            <text>This is the header</text>
            <heading-level>Heading 2</heading-level>
        </header>
        <text>
            <content>
                <p>Text 
                    <strong>Here</strong>
                </p>
                <p>
                    <span style="text-decoration: underline;">
                        <strong>And Here</strong>
                    </span>
                </p>
            </content>
            <has-media>Yes</has-media>
            <media>
                <media-type>Image</media-type>
                <image type="file">
                    <content />
                    <path>/images/sig_placeholder.png</path>
                    <link>site://WDG F1 - Velocity/images/sig_placeholder.png</link>
                    <site>WDG F1 - Velocity</site>
                    <name>sig_placeholder.png</name>
                </image>
                <alt-tag>Picture alt tag</alt-tag>
                <image-options>
                    <value>Caption</value>
                    <value>Credit</value>
                </image-options>
                <caption>image caption</caption>
                <credit>image credit</credit>
                <type-of-video>YouTube</type-of-video>
                <video_id />
                <alignment>Left</alignment>
                <width>75%</width>
            </media>
        </text>
    </page-element>
</system-data-structure>
XSL:
#macro(page_element $local_block)
    #set ($content_type = $local_block.getStructuredDataNode("page-element/content-type").textValue)
        #if ($content_type == "Text (w/ Supporting Media)")
            #default_text($local_block)
        #end
#end
#macro (default_text $local_block)
    #set ($image_path = $local_block.getStructuredDataNode("page-element/text/media/image/path").textValue)
#end
  1. 1 Posted by Ryan Griffith on 17 Feb, 2015 07:42 PM

    Ryan Griffith's Avatar

    Hi,

    It looks as though you are mixing a little bit of XPath with the Locator Tool. Specifically, when using getStructuredDataNode you want to check to see if there is a chosen asset, then use the chooser asset's path.

    When you have a moment, give the following a try and let me know how it works out:

    #set ($image = $local_block.getStructuredDataNode("page-element/text/media/image"))
    
    ## Make sure there is a chosen image
    #if ($_PropertyTool.isNull($image.asset) == false)
      $image.asset.path
      ## Or, output the link:
      $image.asset.link
    #end
    

    Please let me know if you have any questions.

    Thanks!

  2. Ryan Griffith closed this discussion on 05 Mar, 2015 07:41 PM.

Discussions are closed to public comments.
If you need help with Cascade CMS please start a new discussion.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

 

26 Aug, 2016 01:19 PM
25 Aug, 2016 03:02 PM
25 Aug, 2016 12:50 PM
24 Aug, 2016 08:43 PM
24 Aug, 2016 07:20 PM
21 Aug, 2016 01:20 PM