Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1365502

    HI there,

    I’m trying to change the logo based on a selection. Sadly, this doesn’t seem to work with SVGs. Is there a trick to get that to work with SVGs too? I’ve already installed “SVG Support”.

    add_filter('avf_logo', 'av_change_logo');
    function av_change_logo($logo)
    {
    
      $menuSelect = get_field("header_selection");
      if ($menuSelect == 65) {
        $logo = get_stylesheet_directory_uri()."/logos/(...).svg";
      } elseif ($menuSelect == 69) {
        $logo = get_stylesheet_directory_uri()."/logos/(...).svg";
      } elseif ($menuSelect == 2) {
        $logo = get_stylesheet_directory_uri()."/logos/(...).svg";
      } 
    
      return $logo;
    }
    

    The URL is 100% right and the “normal” logo is already an SVG.

    #1365518

    Hey emilconsor,

    Thank you for the inquiry.

    You can upload the SGV files in the media library and use their ID instead of manually retrieving them from a specific directory.

    add_filter('avf_logo', 'av_change_logo');
    function av_change_logo($logo)
    {
    
      $menuSelect = get_field("header_selection");
      if ($menuSelect == 65) {
        $logo = ID_OF_SVG_IMAGE;
      } elseif ($menuSelect == 69) {
        $logo = ID_OF_SVG_IMAGE;
      } elseif ($menuSelect == 2) {
        $logo = ID_OF_SVG_IMAGE;
      } 
    
      return $logo;
    }
    

    Please note that this will only work if the initial logo is also an SVG image. ID_OF_SVG_IMAGE is the ID of the uploaded SVG image in the Media > Library panel.

    Best regards,
    Ismael

    #1365538

    Hi Ismael,

    worked perfectly. Thank you!

    #1365541

    Hi,

    Glad Ismael could help!

    Let us know if you have any other questions and enjoy the rest of your day :)

    Best regards,
    Yigit

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Change SVG logo on some pages’ is closed to new replies.