0
votes

I'm trying to use some thumbnails for subcategories to get rid of "No Image Available" placeholder.

When I try to add Category Thumbnail without having Cover Image set, it doesn't use it (still uses placeholder "No Image Available").

Is it some sort of bug or a feature? Is there any way to get around it?

I'm using Prestashop 1.6.1.3 with default theme.

Thanks for any help!

1
How are you doing this? - IndrÄ—
I go to Backoffice: Products > Categories > Edit. There I upload it, all using GUI. I ask on it here because I'm affraid it would need some source editing. - Gomi
There is no such a feature to display a category image if a product image is missing in Prestashop. You need a developer help. - IndrÄ—

1 Answers

2
votes

Just ran into this myself. I don't know whether this should be described as a bug or a feature, but it's certainly the way the code is written as of version 1.6.1.4.

In the file /classes/Category.php the getSubCategories() function checks whether a cover image file exists for the current category. Image data is only added to the subcategory data if a cover image exists, otherwise the default placeholder image information is added.

One way round this is to replace:

foreach ($result as &$row) {
    $row['id_image'] = Tools::file_exists_cache(_PS_CAT_IMG_DIR_.$row['id_category'].'.jpg') ? (int)$row['id_category'] : Language::getIsoById($id_lang).'-default';
    $row['legend'] = 'no picture';
}

with

foreach ($result as &$row) {
    if (Tools::file_exists_cache(_PS_CAT_IMG_DIR_.$row['id_category'].'.jpg') || Tools::file_exists_cache(_PS_CAT_IMG_DIR_.$row['id_category'].'-medium_default.jpg')) {
        $row['id_image'] = (int)$row['id_category'];
        $row['legend'] = $row['meta_title'];                        
    } else {
        $row['id_image'] = Language::getIsoById($id_lang).'-default';
        $row['legend'] = 'no picture';
    }
}