Copied to clipboard

Flag this post as spam?

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


  • Morten Balle 38 posts 129 karma points
    Feb 13, 2011 @ 13:54
    Morten Balle
    0

    Dynamic background image via inline xslt

    Hi

    Running version 4.5.2, I've got this in a template

     <div id="content-wrap" style="background-image:url(<umbraco:Item runat="server" field="backgroundImage" xslt="concat('',umbraco.library:GetMedia({0}, true())/umbracoFile, '')" xsltDisableEscaping="true"/>);" >

    It works as intended, showing the backgroundImage, but in my template editor this part 

    " field="backgroundImage" xslt="concat('',umbraco.library:GetMedia({0}, true())/umbracoFile, '')" xsltDisableEscaping="true"/>);" >

    Is it me or version 4.5.2 that' wrong..?

    Best,
    Morten

  • Lesley 284 posts 143 karma points
    Feb 13, 2011 @ 14:42
    Lesley
    0

    Yes, I think you can tidy this up by removing the concat function, which isn't doing anything but joining an empty string on either end of the umbracoFile.

    xslt="umbraco.library:GetMedia( {0}, true() )/umbracoFile"

  • Morten Balle 38 posts 129 karma points
    Feb 13, 2011 @ 16:12
    Morten Balle
    0

    Could do that, still showing the bckg image as intended.

     <div id="content-wrap" style="background-image:url(<umbraco:Item runat="server" field="backgroundImage" xslt="umbraco.library:GetMedia({0}, true())/umbracoFile" xsltDisableEscaping="true"/>);">

    And still with the last part in red as if it's an error:

    " field="backgroundImage" xslt="umbraco.library:GetMedia({0}, true())/umbracoFile" xsltDisableEscaping="true"/>);">

    Thanks anyway...

  • Lesley 284 posts 143 karma points
    Feb 13, 2011 @ 16:28
    Lesley
    1

    Try surrounding the style in single rather than double quotes:

    style='background-image:url(<umbraco:Item runat="server" field="backgroundImage" xslt="umbraco.library:GetMedia({0},true())/umbracoFile" xsltDisableEscaping="true"/>);'

  • Morten Balle 38 posts 129 karma points
    Feb 13, 2011 @ 22:15
    Morten Balle
    0

    Spot on...
    Thanks for you help

    M:orten

  • Amir Khan 1282 posts 2739 karma points
    Apr 12, 2011 @ 17:56
    Amir Khan
    0

    Is it possible to make an inline xslt like this recursive?

  • Amir Khan 1282 posts 2739 karma points
    Apr 12, 2011 @ 18:00
    Amir Khan
    0

    Whoops, just answered that one myself, just had to add "recursive=true" like normal.

    -Amir

  • Indah 1 post 21 karma points
    Oct 30, 2014 @ 04:46
    Indah
    0

    If you want to do it with Macro here is the lines to go to your templates:

     style="background-image:url(<umbraco:Macro Alias="yourbackgroundImageMacroAliasname" runat="server" />)"

Please Sign in or register to post replies

Write your reply to:

Draft