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.
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
Hi Ismael,
worked perfectly. Thank you!