-
Notifications
You must be signed in to change notification settings - Fork 380
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set DefaultMetadataReader when ext-exif is not present
This fixes the issue where an exif reader is used, but ext-exif is not loaded. Closes: #501
- Loading branch information
1 parent
1eac259
commit f3c460a
Showing
3 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
DependencyInjection/Compiler/MetadataReaderCompilerPass.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the `liip/LiipImagineBundle` project. | ||
* | ||
* (c) /~https://github.com/liip/LiipImagineBundle/graphs/contributors | ||
* | ||
* For the full copyright and license information, please view the LICENSE.md | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Liip\ImagineBundle\DependencyInjection\Compiler; | ||
|
||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
|
||
/** | ||
* By default, a metadata reader based on the exif php extension is used. | ||
* This compiler pass checks if the extension is loaded an switches to a simpler | ||
* implementation if not. | ||
*/ | ||
class MetadataReaderCompilerPass implements CompilerPassInterface | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function process(ContainerBuilder $container) | ||
{ | ||
if ( | ||
!extension_loaded('exif') | ||
&& $container->getParameter('liip_imagine.meta_data.reader.class') === 'Imagine\Image\Metadata\ExifMetadataReader' | ||
) { | ||
$container->setParameter('liip_imagine.meta_data.reader.class', 'Imagine\Image\Metadata\DefaultMetadataReader'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters