1. HOT Divi Ultimate Header Plugin - Design Divi custom header globally in Divi Builder: https://header.diviultimate.com/
    Dismiss Notice

Image as div background

Discussion in 'Get Help On Divi Wordpress' started by Josue Rodriguez, Jun 12, 2019 at 7:49 PM.

  1. Josue Rodriguez

    Josue Rodriguez New Member
    Divi Ultimate Header Plugin Divi Ultimate Footer Plugin

    So I am trying to setup a custom image field in a custom page template as the background of my header.
    Here is the code I am using to get the image to show:
    <?php

    $image = get_field('header_image');

    if( !empty($image) ): ?>

    <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />

    <?php endif; ?>

    If I include this code in my page template by itself it shows up fine in the page, but I try to set it as a background to a div using style="background option inside the division, it won't show.

    Anyone here that can help?

    Thanks,

    Josh
     
  2. Divi.Help

    Divi.Help Administrator
    Staff Member

    Something like this should work:
    Code:
    <div style="background-image: url(<?php echo $image['url']; ?>) ">