Viewing 4 posts - 1 through 4 (of 4 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

    #1483416

    Hi!

    No cache plugin is active. When switching “Delete Old CSS And JS Files?” option, the cache seems to be deleted, but then again, all posts of the CPT is getting the same CSS class and therefore same rules apply.
    The problem is not the external cache, but the avia cache. It is wrongly assigning background-image to element class, although it is different for each post.

    It should either add background-image as inline style as in my example or generate a unique uid for each post.

    Regards
    Bence

    #1483471

    Hi,

    The theme does store the _av_css_styles in the database, but this is done for every page or post, so it should be unique. Which element class are you referring to? Please create a test page and provide the site details in the private field — screenshots will also help.

    Best regards,
    Ismael

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