RicRey Posted February 15, 2022 Share Posted February 15, 2022 Hello, I have a module that is free, and it is very useful to me, but I would like it to take the images of a specific size and not the pure size as it currently does... for example I want it to take the images from "manufacturer_default" but it does it directly and that makes them very heavy. Is there a way that you can help me?, I paste part of the code in case someone can. protected function _prepareHook() { if(!explode(',',Configuration::get('YBC_MF_MANUFACTURERS'))) return; switch(Configuration::get('YBC_MF_MANUFACTURER_ORDER')) { case 'name_desc': $order = 'name desc'; break; case 'manu_asc': $order = 'id_manufacturer asc'; break; case 'manu_desc': $order = 'id_manufacturer desc'; break; default: $order = 'name asc'; break; } $manufacturers = $this->getManufactures($order, (int)Configuration::get('YBC_MF_MANUFACTURER_NUMBER') > 0 ? (int)Configuration::get('YBC_MF_MANUFACTURER_NUMBER') : false); foreach ($manufacturers as &$manufacturer) { if(file_exists(_PS_MANU_IMG_DIR_.$manufacturer['id_manufacturer'].'.jpg')) $manufacturer['image'] = _THEME_MANU_DIR_.$manufacturer['id_manufacturer'].'.jpg'; else $manufacturer['image'] = $this->_path.'images/default_logo.jpg'; } $this->smarty->assign(array( 'manufacturers' => $manufacturers, 'YBC_MF_TITLE' => Configuration::get('YBC_MF_TITLE', (int)$this->context->language->id), 'YBC_MF_SHOW_NAME' => (int)Configuration::get('YBC_MF_SHOW_NAME'), 'YBC_MF_PER_ROW_DESKTOP' => (int)Configuration::get('YBC_MF_PER_ROW_DESKTOP'), 'YBC_MF_PER_ROW_MOBILE' => (int)Configuration::get('YBC_MF_PER_ROW_MOBILE'), 'YBC_MF_PER_ROW_TABLET' => (int)Configuration::get('YBC_MF_PER_ROW_TABLET'), 'YBC_MF_SHOW_NAV' => (int)Configuration::get('YBC_MF_SHOW_NAV'), 'YBC_MF_AUTO_PLAY' => (int)Configuration::get('YBC_MF_AUTO_PLAY'), 'YBC_MF_PAUSE' => (int)Configuration::get('YBC_MF_PAUSE'), 'YBC_MF_SPEED' => (int)Configuration::get('YBC_MF_SPEED') > 0 ? (int)Configuration::get('YBC_MF_SPEED') : 5000, 'link' => $this->context->link, 'view_all_mnf' => $this->context->link->getPageLink('manufacturer') )); return $this->display(__FILE__, 'manufacturers.tpl'); Link to comment Share on other sites More sharing options...
Ress Posted February 18, 2022 Share Posted February 18, 2022 You can generate manufacturer image link like this: $manufacturer['image'] = $this->context->link->getManufacturerImageLink($manufacturer['id_manufacturer'], 'medium_default'); You can replace medium_default with the type of image you want, but which is available for the brand. Link to comment Share on other sites More sharing options...
Paul C Posted February 18, 2022 Share Posted February 18, 2022 I just pass the $manufacturers variable to smarty and then you can pick the image size to use from there e.g.: In the module: $manufacturers = Manufacturer::getManufacturers(); $this->smarty->assign(array('manufacturers' => $manufacturers, 'mylink' => $this->context->link)); Then in the template you can pick the image and : {foreach $manufacturers item=manufacturer name=manufacturers} <li> <a href="{$mylink->getmanufacturerLink($manufacturer.id_manufacturer, $manufacturer.link_rewrite)}" title="{$manufacturer.name|escape:'htmlall':'UTF-8'}"> <img src="{$urls.img_ps_url}/m/{$manufacturer.id_manufacturer}-small_default.jpg" alt="{$manufacturer.name|escape:'htmlall':'UTF-8'}" height="120px;" width="120px;" > </a> </li> {/foreach} The above was heavily edited from an old project (and it's late!) so apologies for any typos.... obviously you want to pick the thumbnail size that most closely matches the size you want the image. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now