Commit d7497b03 authored by catch's avatar catch

Issue #3015708 by alexpott: Properly deprecate RESPONSIVE_IMAGE_* constants

parent 08555611
......@@ -10,6 +10,7 @@
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\image\Entity\ImageStyle;
use Drupal\responsive_image\Entity\ResponsiveImageStyle;
use Drupal\responsive_image\ResponsiveImageStyleInterface;
use Drupal\Core\Image\ImageInterface;
use Drupal\breakpoint\BreakpointInterface;
......@@ -488,7 +489,7 @@ function _responsive_image_build_source_attributes(array $variables, BreakpointI
*/
function responsive_image_get_image_dimensions($image_style_name, array $dimensions, $uri) {
// Determine the dimensions of the styled image.
if ($image_style_name == RESPONSIVE_IMAGE_EMPTY_IMAGE) {
if ($image_style_name == ResponsiveImageStyleInterface::EMPTY_IMAGE) {
$dimensions = [
'width' => 1,
'height' => 1,
......@@ -513,12 +514,12 @@ function responsive_image_get_image_dimensions($image_style_name, array $dimensi
* The MIME type of the image after the image style is applied.
*/
function responsive_image_get_mime_type($image_style_name, $extension) {
if ($image_style_name == RESPONSIVE_IMAGE_EMPTY_IMAGE) {
if ($image_style_name == ResponsiveImageStyleInterface::EMPTY_IMAGE) {
return 'image/gif';
}
// The MIME type guesser needs a full path, not just an extension, but the
// file doesn't have to exist.
if ($image_style_name === RESPONSIVE_IMAGE_ORIGINAL_IMAGE) {
if ($image_style_name === ResponsiveImageStyleInterface::ORIGINAL_IMAGE) {
$fake_path = 'responsive_image.' . $extension;
}
else {
......@@ -531,7 +532,7 @@ function responsive_image_get_mime_type($image_style_name, $extension) {
* Wrapper around image_style_url() so we can return an empty image.
*/
function _responsive_image_image_style_url($style_name, $path) {
if ($style_name == RESPONSIVE_IMAGE_EMPTY_IMAGE) {
if ($style_name == ResponsiveImageStyleInterface::EMPTY_IMAGE) {
// The smallest data URI for a 1px square transparent GIF image.
// http://probablyprogramming.com/2009/03/15/the-tiniest-gif-ever
return 'data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
......
......@@ -81,8 +81,8 @@ public function form(array $form, FormStateInterface $form_state) {
];
$image_styles = image_style_options(TRUE);
$image_styles[RESPONSIVE_IMAGE_ORIGINAL_IMAGE] = $this->t('- None (original image) -');
$image_styles[RESPONSIVE_IMAGE_EMPTY_IMAGE] = $this->t('- empty image -');
$image_styles[ResponsiveImageStyleInterface::ORIGINAL_IMAGE] = $this->t('- None (original image) -');
$image_styles[ResponsiveImageStyleInterface::EMPTY_IMAGE] = $this->t('- empty image -');
if ((bool) $responsive_image_style->id() && $this->operation != 'duplicate') {
$description = $this->t('Select a breakpoint group from the installed themes and modules. Below you can select which breakpoints to use from this group. You can also select which image style or styles to use for each breakpoint you use.') . ' ' . $this->t("Warning: if you change the breakpoint group you lose all your image style selections for each breakpoint.");
......
......@@ -2,6 +2,7 @@
namespace Drupal\Tests\responsive_image\Functional;
use Drupal\responsive_image\ResponsiveImageStyleInterface;
use Drupal\Tests\BrowserTestBase;
/**
......@@ -73,7 +74,7 @@ public function testResponsiveImageAdmin() {
['wide', '2x'],
];
$image_styles = array_merge(
[RESPONSIVE_IMAGE_EMPTY_IMAGE, RESPONSIVE_IMAGE_ORIGINAL_IMAGE],
[ResponsiveImageStyleInterface::EMPTY_IMAGE, ResponsiveImageStyleInterface::ORIGINAL_IMAGE],
array_keys(image_style_options(FALSE))
);
foreach ($cases as $case) {
......
......@@ -7,6 +7,7 @@
use Drupal\file\Entity\File;
use Drupal\responsive_image\Plugin\Field\FieldFormatter\ResponsiveImageFormatter;
use Drupal\responsive_image\Entity\ResponsiveImageStyle;
use Drupal\responsive_image\ResponsiveImageStyleInterface;
use Drupal\Tests\image\Functional\ImageFieldTestBase;
use Drupal\Tests\TestFileCreationTrait;
use Drupal\user\RoleInterface;
......@@ -123,7 +124,7 @@ protected function addTestImageStyleMappings($empty_styles = FALSE) {
// Test the output of an empty image.
->addImageStyleMapping('responsive_image_test_module.mobile', '1x', [
'image_mapping_type' => 'image_style',
'image_mapping' => RESPONSIVE_IMAGE_EMPTY_IMAGE,
'image_mapping' => ResponsiveImageStyleInterface::EMPTY_IMAGE,
])
// Test the output with a 1.5x multiplier.
->addImageStyleMapping('responsive_image_test_module.mobile', '1.5x', [
......@@ -149,7 +150,7 @@ protected function addTestImageStyleMappings($empty_styles = FALSE) {
// Test the output of the original image.
->addImageStyleMapping('responsive_image_test_module.wide', '3x', [
'image_mapping_type' => 'image_style',
'image_mapping' => RESPONSIVE_IMAGE_ORIGINAL_IMAGE,
'image_mapping' => ResponsiveImageStyleInterface::ORIGINAL_IMAGE,
])
->save();
}
......@@ -358,7 +359,7 @@ public function testResponsiveImageFieldFormattersEmptyMediaQuery() {
// Test the output of an empty media query.
->addImageStyleMapping('responsive_image_test_module.empty', '1x', [
'image_mapping_type' => 'image_style',
'image_mapping' => RESPONSIVE_IMAGE_EMPTY_IMAGE,
'image_mapping' => ResponsiveImageStyleInterface::EMPTY_IMAGE,
])
// Test the output with a 1.5x multiplier.
->addImageStyleMapping('responsive_image_test_module.mobile', '1x', [
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment