Adding the Perch image tag to background-image url();

  • Hi,


    I want to allow users to upload a background image for a <section> on my site.


    After referencing this thread, I wrote this:


    <section id="section1" style="background-image:url('

    Code
    1. <section id="section1" style="background-image:url('<perch:content id="bgimage" type="image" label="BG Image">');">

    When I do this, the code editor seems to flag an error with the quotations:87-screen-shot-2019-08-01-at-11-46-26-am-png


    And when I load the page, this is how it still looks in the inspector:

    88-screen-shot-2019-08-01-at-11-47-52-am-png


    No idea how to resolve this. I've tried changing up the order of the quotations (double/single, etc) and nothing seems to work.


    Thoughts? Thanks!

  • drewm

    Approved the thread.
  • Hi


    Are you using this in a content (html) template? <perch:content… can't go in a page (php) template.


    A good way to test it might be to render the image tag outside the section first so the image path displays on the screen and then move it into the section style attribute once you know it's working.


    Also your section and style tag don't look closed to me in your screen grab. It's missing the ')"> but that might just be the image. Best to post the actual code for clarity's sake.


    Jon