Change responsive size image ratio, how to do?

LiteCart Fan
از کشور Netherlands
عضو از مارس 2021

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?
LiteCart Fan
از کشور Netherlands
عضو از مارس 2021

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
از کشور Sweden
عضو از مهٔ 2013
tim

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;```
LiteCart Fan
از کشور Netherlands
عضو از مارس 2021

Thank you! with img-responsive it works for me.

This thread has been closed due to long inactivity. Posting to it is not possible.
This website uses no cookies and no third party tracking technology. We think we can do better than others and really think about your privacy.