Change responsive size image ratio, how to do?

LiteCart Fan
Depuis Netherlands
Membre depuis mars 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
Depuis Netherlands
Membre depuis mars 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
Depuis Sweden
Membre depuis mai 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
Depuis Netherlands
Membre depuis mars 2021

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

Ce fil de discussion a été fermé en raison d'une longue inactivité. Il n'est pas possible de publier dessus.
Ce site n'utilise aucun cookie ni aucune technologie de suivi tierce. Nous pensons pouvoir faire mieux que les autres et nous nous soucions vraiment de votre vie privée.