Skip Navigation

[Resolved] Background image from a custom field in Divi specialty section

This thread is resolved. Here is a description of the problem and solution.

Problem: I would like to use a custom field image as the background of a Divi specialty section.

Solution: The best way to use a custom field as a background image with the Divi builder is to use a text module and add inline CSS to a wrapper element. It is not possible to place a Toolset shortcode in a Divi module's styles editor, because Divi does not support any shortcodes here.

This support ticket is created 6 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 4 replies, has 2 voices.

Last updated by karlT-3 6 years, 6 months ago.

Assisted by: Christian Cox.

Author
Posts
#955615

Hello,

I am trying to use an image custom field ("blog-header-image) as the 'background image' in a Divi specialty section, but am not having much luck.

I have created a Custom Template in Toolset, with all other elements working correctly on the page. However, I cannot seem to call the "blog-header-image" custom field correctly using either the Divi Builder or Toolset's Content Template editor.

Any help would be greatly appreciated.

Thanks,
Karl.

#955668

Hi, the best way I can think of to use a custom field image as a background image is to apply inline CSS directly to an HTML element. For example, in a Text module, you can do something like this in the Text tab:

<div style="background-image: url('{!{types field='blog-header-image' url='true' }!}{!{/types}!}');">
  This content will have the custom field background image.
</div>
#955711

Hi Christian,

Thank you for your reply.

I'm trying to put the image into the background of a "section module setting" - I can't put a text module here for the above code. The only options I have when inserting the background image for the Section is insert via URL or from the media library.

Cheers,
Karl.

#956554

There's no easy way to add a dynamic CSS attributes to a module like this, because the Divi Builder doesn't support shortcodes or dynamic values in these inputs. Similarly, it is not possible to generate a dynamic CSS classname using shortcodes. Unfortunately these are limitations of Divi Builder that Toolset cannot fix. If it's essential to your site design, you can consider using multiple Content Templates, nested inside one another. Apply your dynamic CSS styles to a wrapper element and insert a nested Content Template containing Divi module design.

#957172

Thanks Christian - that makes sense! Appreciate the guidance.

Many thanks,
Karl.