From f6c37251ce3117eb5d17ce2623e816816b074aae Mon Sep 17 00:00:00 2001 From: John Franklin <john.franklin@bixal.com> Date: Sun, 1 Dec 2024 15:28:33 -0500 Subject: [PATCH] Another pass with phpcbf. --- .../FieldFormatter/BgImgFieldFormatter.php | 75 ++++++++++--------- 1 file changed, 38 insertions(+), 37 deletions(-) diff --git a/src/Plugin/Field/FieldFormatter/BgImgFieldFormatter.php b/src/Plugin/Field/FieldFormatter/BgImgFieldFormatter.php index 15bf81f..2893b78 100644 --- a/src/Plugin/Field/FieldFormatter/BgImgFieldFormatter.php +++ b/src/Plugin/Field/FieldFormatter/BgImgFieldFormatter.php @@ -387,45 +387,46 @@ class BgImgFieldFormatter extends ResponsiveImageFormatter implements ContainerF else { $breakpoints = $this->breakpointManager->getBreakpointsByGroup($responsive_image_style->getBreakpointGroup()); foreach (array_reverse($responsive_image_style->getKeyedImageStyleMappings()) as $breakpoint_id => $multipliers) { - if (isset($breakpoints[$breakpoint_id])) { - $multipliers = array_reverse($multipliers); - $query = $breakpoints[$breakpoint_id]->getMediaQuery(); - - if ($query != "") { - $css .= ' @media ' . $query . ' {'; - } - - foreach ($multipliers as $multiplier => $mapping) { - $multiplier = rtrim($multiplier, "x"); - - if ($mapping['image_mapping_type'] != 'image_style') { - continue; - } - - if ($mapping['image_mapping'] == "_original image_") { - $url = $this->fileUrlGenerator->generateAbsoluteString($image->getFileUri()); - } else { - // Use image style URL generation instead of ImageFactory->load() - $image_style = $this->entityTypeManager->getStorage('image_style')->load($mapping['image_mapping']); - $url = $image_style->buildUrl($file->getFileUri()); - } - - if ($multiplier != 1) { - $css .= ' @media (-webkit-min-device-pixel-ratio: ' . $multiplier . '), (min-resolution: ' . $multiplier * 96 . 'dpi), (min-resolution: ' . $multiplier . 'dppx) {'; - } - $css .= $selector . ' {background-image: url(' . $url . ');}'; - - if ($multiplier != 1) { - $css .= '}'; - } - } - - if ($query != "") { - $css .= '}'; - } + if (isset($breakpoints[$breakpoint_id])) { + $multipliers = array_reverse($multipliers); + $query = $breakpoints[$breakpoint_id]->getMediaQuery(); + + if ($query != "") { + $css .= ' @media ' . $query . ' {'; + } + + foreach ($multipliers as $multiplier => $mapping) { + $multiplier = rtrim($multiplier, "x"); + + if ($mapping['image_mapping_type'] != 'image_style') { + continue; + } + + if ($mapping['image_mapping'] == "_original image_") { + $url = $this->fileUrlGenerator->generateAbsoluteString($image->getFileUri()); + } + else { + // Use image style URL generation instead of ImageFactory->load() + $image_style = $this->entityTypeManager->getStorage('image_style')->load($mapping['image_mapping']); + $url = $image_style->buildUrl($file->getFileUri()); + } + + if ($multiplier != 1) { + $css .= ' @media (-webkit-min-device-pixel-ratio: ' . $multiplier . '), (min-resolution: ' . $multiplier * 96 . 'dpi), (min-resolution: ' . $multiplier . 'dppx) {'; + } + $css .= $selector . ' {background-image: url(' . $url . ');}'; + + if ($multiplier != 1) { + $css .= '}'; + } + } + + if ($query != "") { + $css .= '}'; } + } } - } + } return $css; } -- GitLab