Skip to content
Snippets Groups Projects
Commit a0539080 authored by Angie Byron's avatar Angie Byron
Browse files

Issue #3085908 by bnjmnm, dww, nightlife2008: Blurry/skewed thumbnails in IE11

parent 1c9842d1
No related branches found
No related tags found
6 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!1012Issue #3226887: Hreflang on non-canonical content pages,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10,!596Issue #3046532: deleting an entity reference field, used in a contextual view, makes the whole site unrecoverable,!496Issue #2463967: Use .user.ini file for PHP settings,!144Issue #2666286: Clean up menu_ui to conform to Drupal coding standards
......@@ -387,6 +387,16 @@
overflow: hidden;
text-align: center;
background-color: #ebebeb;
background-size: 0;
}
/* Required for IE11 due to it not supporting object-fit */
/* @todo Remove this cruft when core officially drops support for IE11. */
/* @see https://www.drupal.org/project/drupal/issues/3089196 */
@media screen and (-ms-high-contrast: active), screen and (-ms-high-contrast: none) {
.media-library-item--grid .field--name-thumbnail {
background-size: auto;
}
}
.media-library-item--grid .field--name-thumbnail img {
......@@ -395,6 +405,15 @@
object-position: center center;
}
/* Required for IE11 due to it not supporting object-fit */
/* @todo Remove this cruft when core officially drops support for IE11. */
/* @see https://www.drupal.org/project/drupal/issues/3089196 */
@media screen and (-ms-high-contrast: active), screen and (-ms-high-contrast: none) {
.media-library-item--grid .field--name-thumbnail img {
opacity: 0;
}
}
.media-library-item--grid.is-hover:before,
.media-library-item--grid.checked:before,
.media-library-item--grid.is-focus:before {
......
......@@ -17,6 +17,7 @@
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Template\Attribute;
use Drupal\Core\Url;
use Drupal\file\Entity\File;
use Drupal\image\Entity\ImageStyle;
use Drupal\image\Plugin\Field\FieldType\ImageItem;
use Drupal\media\MediaTypeForm;
......@@ -94,6 +95,27 @@ function media_library_theme() {
];
}
/**
* Implements hook_preprocess_field().
*
* @todo Remove this cruft when core officially drops support for IE11.
* @see https://www.drupal.org/project/drupal/issues/3089196
*/
function media_library_preprocess_field(&$variables, $hook) {
// IE11 does not support object-fit, so the thumbnail image is added as a
// background image that is seen only in IE11.
$element = $variables['element'];
if ($element['#view_mode'] === 'media_library' && $element['#field_name'] === 'thumbnail' && !empty($element[0]['#item'])) {
if (get_class($element[0]['#item']) === ImageItem::class) {
if ($fid = $element[0]['#item']->target_id) {
$uri = File::load($fid)->getFileUri();
$image_url = ImageStyle::load($element[0]['#image_style'])->buildUrl($uri);
$variables['attributes']['style'] = "background-image: url($image_url); background-repeat: no-repeat; background-position: center;";
}
}
}
}
/**
* Implements hook_views_post_render().
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment