You could use the plugin “Custom Field Template” to replace standard custom fields with a much easier to use interface, that also allows you to use checkboxes, selects, textareas with tinymce, and file uploads among others.
Then the client would just upload the image through that field and you use
<?php
$bg = wp_get_attachment_image_src(get_post_meta($post->ID, 'custom_field_name', true),'original');
?>
to get the file information. that will return an array, and the image url will be the 0 value. You then do:
<?php
if(isset($bg) && $bg != '')) {
echo '<div style="background:url('.$bg[0];.');">CONTENT</div>';
}
?>
Related Posts:
- automatically set “Featured Image” the same as the og:i that is set in a custom field
- Add url from Custom Field as ‘Featured Image’. Code not working
- For homepage images (for small business website), is it better to use custom fields or post_thumbnail?
- Custom field as featured image caption
- Selectively hiding or allowing thumbnails of featured images on front page
- Use a different catalog image than the featured image
- Crop custom image size vs actual size
- Remove Dimension from wp_get_attachment_image
- Change wp_get_attachment_image attributes (src and srcset) on specific custom field
- Move from old custom field to new post_thumbnails
- How do I make a custom field choose an image?
- Extend WP Customizer to make multiple image selection possible
- Is there a hook / action that is triggered when adding or removing a post thumbnail?
- Add multiple images to a page sidebar
- Display thumbnail from custom field
- Add custom field to image editor
- Display info from custom fields in all images’ HTML
- How can I migrate all of my custom field thumbnails to the built-in post featured image?
- copy attachments to another post type and change attachment url
- limit amount of photos uploaded per cpt post
- Adding a custom field or metabox to the post-thumbnail widget?
- Metabox with multiple fields added by user and upload box
- Add WYSIWYG to Image Description field
- Deleted pages showing up when querying for child pages
- Get Meta from Custom Field of Image URL
- How to display multiple images in custom field
- How to add image attachment to post from a single meta key (Woocommerce)
- Exclude images uploaded via meta boxes from WordPress gallery
- How do I Add images uploaded in the post to a default custom field
- How to add the image URL from an external RSS feed and insert into a custom field?
- Add new image block, set default class name and update it using Javascript
- Better way to save image in custom field
- How do I add an image upload, custom field to a WooCommerce product?
- Select multiple images from custom field
- Redirect to another page using contact form 7? [closed]
- How to mass update custom fields for more than 20k posts
- how to make nsfw post with thumbanil
- Displaying page image in the footer automatically
- Get image url using image id
- Can I use a Custom Field as the Featured Image URL?
- Show image if author meta (profile fields) exists outside loop
- Getting the Featured image URL and inserting it as Custom Field on Post update / publish
- Convert attachment ID into url?
- User customising position of WordPress Featured Image
- Set featured image from custom field URL
- Display a different image for each page with editor
- WP Insert post with post_thumbnail
- Custom field image to Featured Image
- Image upload and path to custom field
- How to get custom image field of specific post id
- Add image URL automatically to custom field?
- wp_get_attachment_image_src() with advanced custom fields returning empty
- Unable to select image with custom field
- Users uploaded image and matching an id or taxonomy
- Adding Facebook’s image and meta description retrieval capabilities to a WordPress post
- use custom field value as featured image
- Can you generate a featured image from two images from custom fields?
- Show image depending on the number in the custom fields
- How to delete attachments associated with custom field type when post property changes? [closed]
- How to add custom fields to images for image source text and URL
- Automatically set the_post_thumbnail to Custom Field Value
- Get first URL from custom field, download and set as featured image on post publish
- Change path to child of page when uploading image via custom field
- Related post thumbnail not showing up
- Analyze uploaded images to get colour values
- Adding thumbnails for non-image attachments
- Post thumbnail size for custom field only
- Upload image to wordpress
- Undefined Variable (Displaying image via custom field)
- Multiple image uploader under editor?
- Get single image from custom fields made with WCK custom fields creator
- Add image custom attribute [closed]
- Custom field for image, not showing image!
- Show/Hide Featured Image or replace it with custom field [closed]
- Display Additional Info
- how to create meta key name in wp_usermeta table in database
- Redirect DRAFT Posts to a Custom URL (Custom Field) : Currently 404 Page
- Display the output from Custom User Fields from a WordPress user profile on a WordPress Custom Page
- How to use custom fields like Title to show value in content?
- Populate custom checkout fields with data from previous orders
- Need to search a custom field (ingredients, one long string per post), but want it to allow phrases/non-exact matches
- Meta field bulk editing no longer working in WP 6.0 [closed]
- How do I upload file through custom field, save it to database and get it
- Can export gallery but can’t import it Wp all import
- Get Custom Field Name ( Label or Key ) Not Value
- Compare ACF date field (if exists) and post date and order DESC
- How To Save Data From Remote APIs To ACF?
- Custom Field: how to save array of multiple key-values in WordPress
- comments_where Hook
- Custom field on Quick Edit using select/dropdown – almost working right but not showing currently selected value
- How can I detect user’s timezone?
- Rewrite comment form post ID on submit
- Add WordPress user custom meta to chartjs vertically stacked chart in Divi theme
- show a specific metabox dependent on the page template
- ACF field group not showing in page
- excluding posts by an ACF field in pagination
- Type character in name and make it invisble
- Filter post style attribute
- What am I missing in this Code Block?
- Making WP_Query limit results by date before today where date is a meta_query