Skip to content
Snippets Groups Projects
Commit 20848145 authored by Steven Jones's avatar Steven Jones Committed by Steven Jones
Browse files

Issue #2805031 by Steven Jones: Modify image style list to display pipeline used

parent 34b02d52
No related branches found
No related tags found
No related merge requests found
......@@ -40,7 +40,8 @@ function imageapi_optimize_entity_type_alter(array &$entity_types) {
/** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */
if (isset($entity_types['image_style'])) {
$image_style = $entity_types['image_style'];
$image_style->setClass('\Drupal\imageapi_optimize\Entity\ImageStyleWithPipeline');
$image_style->setClass('Drupal\imageapi_optimize\Entity\ImageStyleWithPipeline');
$image_style->setHandlerClass('list_builder', 'Drupal\imageapi_optimize\ImageStyleWithPipelineListBuilder');
$config_export = $image_style->get('config_export');
$config_export[] = 'pipeline';
$image_style->set('config_export', $config_export);
......
......@@ -9,6 +9,9 @@ class ImageStyleWithPipeline extends ImageStyle {
//@TODO: maybe this should be something other than a 'random' string.
protected $pipeline = '__default__';
/**
* {@inheritdoc}
*/
public function createDerivative($original_uri, $derivative_uri) {
$result = parent::createDerivative($original_uri, $derivative_uri);
......
<?php
namespace Drupal\imageapi_optimize;
use Drupal\Core\Entity\EntityInterface;
use Drupal\image\ImageStyleListBuilder;
class ImageStyleWithPipelineListBuilder extends ImageStyleListBuilder {
/**
* {@inheritdoc}
*/
public function buildHeader() {
$header = parent::buildHeader();
$header['pipeline'] = $this->t('Image Optimize Pipeline');
return $header;
}
/**
* {@inheritdoc}
*/
public function buildRow(EntityInterface $entity) {
/** @var \Drupal\imageapi_optimize\Entity\ImageStyleWithPipeline $entity */
$pipelineNames = imageapi_optimize_pipeline_options(FALSE);
$row = parent::buildRow($entity);
$row['pipeline'] = isset($pipelineNames[$entity->getPipeline()]) ? $pipelineNames[$entity->getPipeline()] : '';
return $row;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment