Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How about fit preview image into preview image area? #75

Open
bscheshirwork opened this issue Dec 20, 2018 · 1 comment
Open

How about fit preview image into preview image area? #75

bscheshirwork opened this issue Dec 20, 2018 · 1 comment

Comments

@bscheshirwork
Copy link
Contributor

This is some strange:

.gallery-manager .photo img {
    width: 140px;
    height: auto;
}

.gallery-manager .image-preview {
    height: 88px;
    overflow: hidden;
}
    /**
     * Widget preview height
     * @var int
     */
    public $previewHeight = 200;
    /**
     * Widget preview width
     * @var int
     */
    public $previewWidth = 200;

if (!isset($this->versions['preview'])) {
$this->versions['preview'] = function ($originalImage) {
/** @var ImageInterface $originalImage */
return $originalImage
->thumbnail(new Box($this->previewWidth, $this->previewHeight));
};
}

peek 2018-12-20 14-40

@bscheshirwork
Copy link
Contributor Author

So... We can change a preview size and rules:

    /**
     * Widget preview height
     * @var int
     */
    public $previewHeight = 88;
    /**
     * Widget preview width
     * @var int
     */
    public $previewWidth = 130;
            $this->versions['preview'] = function ($originalImage) {
                $imagine = new \Imagine\Imagick\Imagine();
                $image = $imagine->create(new \Imagine\Image\Box($this->previewWidth, $this->previewHeight));
                /** @var ImageInterface $originalImage */
                $thumbnail = $originalImage
                    ->thumbnail(new Box($this->previewWidth, $this->previewHeight));
                $size = $thumbnail->getSize();

                return $image->paste($thumbnail, new \Imagine\Image\Point(floor(($this->previewWidth - $size->getWidth()) / 2), floor(($this->previewHeight - $size->getHeight()) / 2)));
            };

peek 2018-12-20 16-07

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant