Skip to content

Conversation

rtp-cgs
Copy link

@rtp-cgs rtp-cgs commented Apr 24, 2024

For readability I created a new pull request, I hope this is ok.
Related Pull Request: #11

As you mentioned in the related pull request I created an interface for the ImgproxyBuilder class allowing to override it by using the Objects.yaml. Additionally I added the ThumbnailConfiguration object to the ImgproxyBuilder and a addProcessingOption allowing to add processing options inside the generateUrl method using this configuration object.

Example how to override the ImgproxyBuilder class:

Classes/ImgproxyBuilder.php:

class ImgproxyBuilder extends ImgproxyBuilderBase
{
    public function generateUrl(ImgproxyUrl $imgproxyUrl): string
    {
        $configuration = $this->thumbnailConfiguration;
        $focusPointX = ObjectAccess::getProperty($configuration, 'focusPointX', true);
        $focusPointY = ObjectAccess::getProperty($configuration, 'focusPointY', true);

        if (is_float($focusPointX) && is_float($focusPointY)) {
            $focusPointX = ($focusPointX + 1) / 2;
            $focusPointY = ($focusPointY + 1) / 2;

            $imgproxyUrl->addProcessingOption('gravity:fp', $focusPointX . ':' . $focusPointY);
        }

        return parent::generateUrl($imgproxyUrl);
    }
}

Configuration/Objects.yaml:

'Networkteam\ImageProxy\ImgproxyBuilderInterface':
  className: Vendor\ImgProxy\ImgproxyBuilder

Please let me know what you think about this, if this meets your expectations I would also add the example to the README file.

Regards,
Cyrill

@rtp-cgs
Copy link
Author

rtp-cgs commented May 6, 2024

Hello @christophlehmann

I would like to use the original package again in our projects, can you give me a rough idea when this could make it to the main branch?

Regards,
Cyrill

@lneugebauer lneugebauer requested a review from hlubek July 31, 2025 13: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

Successfully merging this pull request may close these issues.

1 participant