magento2-module-image-resizer icon indicating copy to clipboard operation
magento2-module-image-resizer copied to clipboard

Feature request: Add more methods to the interface

Open tdgroot opened this issue 6 years ago • 1 comments

Cool module! I implemented it into a project I'm working on, it works great. A few suggestions, though:

  • Add a method to just resize.
  • Add a method to get absolute path / make the current absolute path method public.
  • Add a method to get relative path / make the current relative path method public.

Please let me know what your thoughts are, I'm willing to contribute!

I had to create my own class to get it working:

<?php

namespace Marissen\QuotationSheet\Helper;

use Magento\Catalog\Model\Product;
use Staempfli\ImageResizer\Model\Resizer;

class ImageResizer extends Resizer
{
    public function getPath(Product $product): string
    {
        $imageObject = $product->getMediaGalleryImages()->getFirstItem();

        if (!$imageObject->getData('url')) {
            return '';
        }

        $this->resizeAndGetUrl($imageObject->getData('url'), 200, 200);

        return $this->getAbsolutePathResized() ?: '';
    }
}

tdgroot avatar Jun 19 '18 12:06 tdgroot

Hi @tdgroot

Thanks for your suggestions If you think that these methods can be handy for other people, we'd be glad to merge your PR.

jalogut avatar Jul 02 '18 12:07 jalogut