ekino / EkinoTinyPngSonataMediaBundle

A Symfony bundle to optimize sonata media images through tinyPNG API
MIT License
1 stars 4 forks source link

Image type detection #2

Open rande opened 5 years ago

rande commented 5 years ago

Should you add a check on the content type before generating an event ?

https://github.com/ekino/EkinoTinyPngSonataMediaBundle/blob/f37c137d8e99868f2d317fdad54a63620382c470/src/Listener/MediaEventSubscriber.php#L166

mazsudo commented 5 years ago

At this point (in a private method of a final class), we have already check that content is a MediaInterface (inside getProvider method https://github.com/ekino/EkinoTinyPngSonataMediaBundle/blob/72e95f0890927cca1fdf5bf6052cd5c225dfb307/src/Listener/MediaEventSubscriber.php#L121 and by type hinting in publishOptimizeMessage signature). Furthermore, only media handled by providers defined in configuration and from png/jpg type (https://github.com/ekino/EkinoTinyPngSonataMediaBundle/blob/72e95f0890927cca1fdf5bf6052cd5c225dfb307/src/Listener/MediaEventSubscriber.php#L129) will launch an event.

Do you think to an additional check?