Jump to content

Get image of category menu

Recommended Posts


I've created a mega menu for my website. I've also added an image to the "menu thumbnail" input.

So this is where the file is located : http://mywebsite.com/img/tmp/category_13-0_thumb.jpg?time=1585727749

I'm overriding the ps_mainmenu.php file in order to add some data to my item menu.


I'm trying to get the image thanks to this, but it's always returning an empty array :

$files = scandir(_PS_TMP_IMG_DIR_);
//        $files = scandir(_PS_CAT_IMG_DIR_);

if (count(preg_grep('/^'.$category['id_category'].'-([0-9])?_thumb.jpg/i', $files)) > 0) {
            foreach ($files as $file) {
                if (preg_match('/^'.$category['id_category'].'-([0-9])?_thumb.jpg/i', $file) === 1) {
                    $image_url = $this->context->link->getMediaLink(_THEME_CAT_DIR_.$file);
                    $thumbnail[] = $image_url;


I'm working on PS 1.7.

Edited by morgandebray (see edit history)

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

  • Create New...

Important Information

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