daniel1983 LiteCart Fan From Netherlands Member since mar. 2021 daniel1983 6 mar. 2023 19:21 I want to change my manufacturer image size to a responsive one so that it moves with it. I found out that it is not displayed properly on my site. $schema_json['brand']['name'] = $product->manufacturer->name; list($width, $height) = functions::image_scale_by_width(240, settings::get('manufacturer_image_ratio')); $_page->snippets['manufacturer'] = [ 'id' => $product->manufacturer->id, 'name' => $product->manufacturer->name, 'image' => [], 'link' => document::ilink('manufacturer', ['manufacturer_id' => $product->manufacturer->id]), ]; if (!empty($product->manufacturer->image)) { $_page->snippets['manufacturer']['image'] = [ 'original' => 'images/' . $product->manufacturer->image, 'thumbnail' => functions::image_thumbnail(FS_DIR_STORAGE . 'images/' . $product->manufacturer->image, $width, $height), 'thumbnail_2x' => functions::image_thumbnail(FS_DIR_STORAGE . 'images/' . $product->manufacturer->image, $width*2, $height*2), 'ratio' => str_replace(':', '/', settings::get('manufacturer_image_ratio')), 'viewport' => [ 'width' => $width, 'height' => $height, ], ]; } }``` This is the code I entered in pages/product, I know that a manufacturers_image_ratio cannot be requested because this is not entered in settings. Can someone help me how to manually set this myself in the code?
daniel1983 LiteCart Fan From Netherlands Member since mar. 2021 daniel1983 6 mar. 2023 20:47 For now I use this line in views/box_product. The problem is only that the size of the image still gets larger than the set 240px, so that's why I started trying something else. <img src="<?php echo document::href_rlink(FS_DIR_STORAGE . $manufacturer['image']['thumbnail']); ?>" srcset="<?php echo document::href_rlink(FS_DIR_STORAGE . $manufacturer['image']['thumbnail']); ?> 1x, <?php echo document::href_rlink(FS_DIR_STORAGE . $manufacturer['image']['thumbnail_2x']); ?> 2x" alt="<?php echo functions::escape_html($manufacturer['name']); ?>" width="100%" max width="240px" height="auto" title="<?php echo functions::escape_html($manufacturer['name']); ?>" />
tim Founder From Sweden Member since mai 2013 tim 6 mar. 2023 22:04 For responsive images assign class="img-responsive" to the <img> element. There is no ratio setting named manufacturer_image_ratio. There is for products and categories only. Either add it to lc_settings or simply define your ratio n the code like this: list($width, $height) = functions::image_scale_by_width(240, '4:1'); You can also set the $width and $height directly like this: $height = 60;```
daniel1983 LiteCart Fan From Netherlands Member since mar. 2021 daniel1983 6 mar. 2023 23:04 Thank you! with img-responsive it works for me.