jonom / silverstripe-focuspoint

Module for improving automatic image cropping in SilverStripe. Adds simple art-direction control by allowing you to set and crop from a focus point instead of the centre point of an image.
MIT License
109 stars 48 forks source link

Check that we return a preview image #74

Closed ohararyan closed 4 years ago

ohararyan commented 4 years ago

Fixes issue #65

If the underlying file for an image has been removed this causes an internal server error.

Call to a member function getWidth() on null
            $w = intval($this->config()->get('max_width'));
            $h = intval($this->config()->get('max_height'));
            $previewImage = $this->image->FitMax($w * 2, $h * 2);
            $state['data'] += [
                'previewUrl' => $previewImage->URL,
                'previewWidth' => $previewImage->getWidth(),
                'previewHeight' => $previewImage->getHeight(),
                'X' => $this->image->getField($this->getName())->getX(),
                'Y' => $this->image->getField($this->getName())->getY()
            ];
jonom commented 4 years ago

@ohararyan what happens in the front-end in this scenario after patching? Do we get front-end errors because of the missing props?

ohararyan commented 4 years ago

@jonom it just ends up with a blank space under the "Focus point" label. It would be nice to hide the field completely IMO but I currently don't have time to look to much further into this.

Screen Shot 2019-12-16 at 10 33 40 AM