Quote from Adam on June 9, 2020, 18:55
To use the taxonomy image feature we have to set term images within the filter even though these may have already been set on the taxonomy. To avoid this, can you add a filter that allows us to override the default image selection and provide an image from the term meta? Just a couple of lines needed in ext/image/view/woof.php e.g.
$term_key = 'images_term_' . $term['term_id'];
$images = isset($woof_settings[$term_key]) ? $woof_settings[$term_key] : array();
$image = '';
// AL: Override image
if (empty($image = apply_filters('woof_taxonomy_image', $image, $term))) {
if (isset($images['image_url']) AND ! empty($images['image_url']))
{
$image = $images['image_url'];
} else
{
continue;
}
if ($images['image_url'] == 'hide')
{
continue;
}
}Then for our custom taxonomy:
add_filter('woof_taxonomy_image', 'motor_make_image_filter', 10, 2);
function motor_make_image_filter($image, $term) {
if ($term['taxonomy'] === "product_brands") {
$image = get_field('make_logo', $term['taxonomy'].'_'.$term['term_id']);
}
return $image;
}Technically no reason to include $image in the filter as done here, but you might want to place the filter after the check if images have been set in the filter settings.
Thanks
P.S. Filter came bundled with theme but happy to go pro if it helps!
To use the taxonomy image feature we have to set term images within the filter even though these may have already been set on the taxonomy. To avoid this, can you add a filter that allows us to override the default image selection and provide an image from the term meta? Just a couple of lines needed in ext/image/view/woof.php e.g.
$term_key = 'images_term_' . $term['term_id'];
$images = isset($woof_settings[$term_key]) ? $woof_settings[$term_key] : array();
$image = '';
// AL: Override image
if (empty($image = apply_filters('woof_taxonomy_image', $image, $term))) {
if (isset($images['image_url']) AND ! empty($images['image_url']))
{
$image = $images['image_url'];
} else
{
continue;
}
if ($images['image_url'] == 'hide')
{
continue;
}
}Then for our custom taxonomy:
add_filter('woof_taxonomy_image', 'motor_make_image_filter', 10, 2);
function motor_make_image_filter($image, $term) {
if ($term['taxonomy'] ==="product_brands") {
$image = get_field('make_logo', $term['taxonomy'].'_'.$term['term_id']);
}
return $image;
}Technically no reason to include $image in the filter as done here, but you might want to place the filter after the check if images have been set in the filter settings.
Thanks
P.S. Filter came bundled with theme but happy to go pro if it helps!