Skip to content

Commit

Permalink
bug #867 Avoid displaying broken images in "show" view (javiereguiluz)
Browse files Browse the repository at this point in the history
This PR was merged into the master branch.

Discussion
----------

Avoid displaying broken images in "show" view

| Before | After
| --- | ---
| ![before](https://cloud.githubusercontent.com/assets/73419/12867722/86d81532-ccf5-11e5-8446-6c6989da1b8c.png) | ![after](https://cloud.githubusercontent.com/assets/73419/12867724/8822001a-ccf5-11e5-8a8e-204ffd9241df.png)

Commits
-------

7970849 Avoid displaying broken images in "show" view
  • Loading branch information
javiereguiluz committed Feb 6, 2016
2 parents 04b467c + 7970849 commit 085a076
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Twig/EasyAdminTwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ public function renderEntityField(\Twig_Environment $twig, $view, $entityName, $
}

if ('image' === $fieldType) {
// avoid displaying broken images when the entity defines no image
if (empty($value)) {
return $twig->render($entityConfiguration['templates']['label_empty'], $templateParameters);
}

// absolute URLs (http or https) and protocol-relative URLs (//) are rendered unmodified
if (1 === preg_match('/^(http[s]?|\/\/).*/i', $value)) {
$imageUrl = $value;
Expand Down

0 comments on commit 085a076

Please sign in to comment.