Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #384710
    #384766

    Hi Kevin!

    Refer to this topic:
    https://kriesi.at/support/topic/change-logo-in-scrolled-header/

    Cheers!
    Josue

    #385192

    Thanks for your reply, Josue. That post was very helpful. I decided to add the scroll logo as a theme option and everything is going very well but I’ve run into one problem. Hopefully you can help.

    I added the following to create a theme option field for the scroll logo:

    add_filter('avf_option_page_data_init', 'pwm_utilities_avf_option_page_data_init', 10, 1);
    function pwm_utilities_avf_option_page_data_init($avia_elements){
    	
    $new_elements[] =	array(
    					"slug"	=> "avia",
    					"name" 	=> __("Scroll Logo", 'avia_framework'),
    					"desc" 	=> __("Upload a logo image, or enter the URL or ID of an image if its already uploaded. This logo is optionally displayed when the user scrolls down the page.", 'avia_framework'),
    					"id" 	=> "scroll_logo",
    					"type" 	=> "upload",
    					"label"	=> __("Use Image as scoll logo", 'avia_framework'));
    
    	$avia_elements = array_merge( $avia_elements, $new_elements );
    
      return $avia_elements;
    }

    And leveraged one of the built in filters to add the CSS for the scroll logo to the dynamic CSS:

    add_filter('avia_dynamic_css_output', 'pwm_avia_dynamic_css_output', 10, 2 );
    function pwm_avia_dynamic_css_output( $output, $color_set ){
    	
    	$scroll_logo = avia_get_option('scroll_logo');
    	if($scroll_logo) :
    		$output .= "header-scrolled .logo img { opacity: 0; }.header-scrolled .logo a { background-image: url($scroll_logo);background-size: contain; background-repeat: no-repeat; }";
    	endif;
    	return $output;
    }

    This all works really well except at some point after my pwm_avia_dynamic_css_output is run, the “http:” gets stripped off the URL for the background image. I can’t figure out where this is happening or why. Can you point me in the right direction?

    Thanks!

    #385196

    Actually after a little more searching, I figured out what’s causing this. For some reason the avia_style_generator class strips http and https out of the rules in class-style-generator.php:

    $rule['value'] = preg_replace('/(http|https):\/\//', '//', $rule['value']);

    Any idea why it does this or how to work around it?

    Thanks!

    #385198

    [deleted]

    #385808

    Hey!

    Does that prevent the scrolled logo from showing? as far as i know a double slash (//) will reference the page protocol and shouldn’t represent a problem.

    Best regards,
    Josue

    #386606

    The scrolled logo does not show when it uses the // method. It only works if I disable that line of code in class-style-generator.php.

    #386758

    Hey!

    It’s strange, i tried reproducing the issue on my local install with no success, the scrolled logo shows. This could work on your end though, replace your pwm_avia_dynamic_css_output filter with:

    add_action('wp_head', 'pwm_avia_dynamic_css_output', 10, 2 );
    function pwm_avia_dynamic_css_output( $output, $color_set ){
    	
    	$scroll_logo = avia_get_option('scroll_logo');
    	if($scroll_logo) :
    
    		echo "<style>.header-scrolled .logo img { opacity: 0; }.header-scrolled .logo a { background-image: url($scroll_logo);background-size: contain; background-repeat: no-repeat; }</style>";
    
    	endif;
    }

    Best regards,
    Josue

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