Custom Fields
Re-Envisioned
Support General Reference image field in css? Reply To: Reference image field in css?

#11932

Anh Tran
Keymaster

To get the image URL, you have to use PHP. So in this case, it’s impossible to put the image URL directly in CSS file. However, you can use PHP to output CSS. Here is a sample code:

$image = rwmb_meta( 'mobile_image' );
if ( $image ) :
    echo '
    @media (max-width: 767px) {
        .page-hero .product-page-hero {
            background-image:url(' . $image['url'] . ');
        }
    }';
endif;