Jump to content

Display (sub)categories mini-images only (when no category images)


Recommended Posts

Hello, 

 

 

 

 

I noticed that Prestashop (default-theme, modified) doesn't display "mini-images" of categories and subcategories when no "category-image" is defined. 

Is anyone familiar with this issue? 
here is my process, and why I don't get it: 

 

- I want my subcategories to be displayed with their "mini-image"

- Sometimes, I don't want to have an category-image (displayed on the category page, as a banner)

- I upload the "mini-image" in the admin

- If there is no category-image, it simply doesn't show up on the website, even though it's showed in the admin... 

 

If anyone has an Idea, I'm all ears! 

 

Thanks a lot

 

 

Share this post


Link to post
Share on other sites

Directly in the Admin -> Categories. When you click to modify a category, you can upload a category-image and* a mini-image (thumb). 

I actually find it faster than a FTP upload, especially since you have to upload 3 versions of each image.. 

 

However, it's non-sense to me that you can upload a thumb, that will show up in the admin, associated to your category, but not on the website itself if you haven't uploaded a "category-image". And I don't get the "why", and most important, the "how to fix this?"

Share this post


Link to post
Share on other sites

That is only used in the menu actually. To be honest, the menu itself uses a pretty silly way to grab it, as there is no built in method:

 

if ((int)$category['level_depth'] > 1 && !$is_children) {
                    $files = scandir(_PS_CAT_IMG_DIR_);

                    if (count(preg_grep('/^'.$category['id_category'].'-([0-9])?_thumb.jpg/i', $files)) > 0) {
                        $html .= '<li class="category-thumbnail">';

                        foreach ($files as $file) {
                            if (preg_match('/^'.$category['id_category'].'-([0-9])?_thumb.jpg/i', $file) === 1) {
                                $html .= '<div><img src="'.$this->context->link->getMediaLink(_THEME_CAT_DIR_.$file)
                                .'" alt="'.Tools::SafeOutput($category['name']).'" title="'
                                .Tools::SafeOutput($category['name']).'" class="imgm" /></div>';
                            }
                        }

                        $html .= '</li>';
                    }
                }

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More