Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1481948

    Hi!

    I was trying to create a custom layout containing a section with a dynamic background (Custom Field Image) value: {wp_custom_field:_thumbnail_id}

    It works OK for one post, but background image is being cached and displayed for all other posts as well.

    I dag into the av_section code to find that attribute is being rendered nicely, but the dynamic CSS class (avia-section.av-m8303wih-f038c6badb9db50289ff3c9a39d18731) that defines section background does not update.

    A quick workaround for this scenario:

    // Force bg for secion as it does not update when dynamic avia element is used
    // Enfold forces CSS bg, but it is cached and does not update for different posts
    //  although it is calculated OK for secion atts
    add_filter('avf_sc_section_before_close', function($output, $atts) {
    	if (!$atts['src_dynamic'] ?? false || !$atts['src'] ?? false)
    		return $output;
    
    	$style_attr = ' style="background-image: url('. esc_url($atts['src']) .') !important;"';
    
    	return substr_replace($output, $style_attr, 4, 0);
    }, 999, 2);
    #1482077

    Hey mcbusta,

    Thank you for the inquiry.

    Glad to know that you managed to find a workaround. Which cache plugin are you using? Have you tried excluding the post css file containing the background style from cache? You can also try excluding the whole dynamic_avia folder in the wp-content/uploads folder.

    Best regards,
    Ismael

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.