Skip to content
Snippets Groups Projects
Commit 14b39095 authored by project update bot's avatar project update bot Committed by Martin Anderson-Clutz
Browse files

Issue #3452027 by Project Update Bot, mandclu: Automated Drupal 11...

Issue #3452027 by Project Update Bot, mandclu: Automated Drupal 11 compatibility fixes for openai_images
parent 93eb53a7
No related branches found
No related tags found
1 merge request!2Automated Project Update Bot fixes
Pipeline #198062 passed with warnings
......@@ -2,7 +2,7 @@ name: openAI Images
description: 'Provides AI generated images for media from open AI API.'
package: Media
type: module
core_version_requirement: ^9.2 || ^10
core_version_requirement: ^9.2 || ^10 || ^11
configure: openai_images.settings
dependencies:
- drupal:media
<?php
use Drupal\Component\Utility\DeprecationHelper;
use Drupal\Core\Render\Element;
use Drupal\Core\Url;
......@@ -35,7 +36,19 @@ function openai_images_preprocess_image_widget(&$variables)
if (!empty($element['fids']['#value'])) {
$file = reset($element['#files']);
$element['file_' . $file->id()]['filename']['#suffix'] = ' <span class="file-size">(' . format_size($file->getSize()) . ')</span> ';
if (!class_exists(DeprecationHelper::class)) {
// @phpstan-ignore-next-line
$formatted_size = format_size($file->getSize());
}
else {
$formatted_size = DeprecationHelper::backwardsCompatibleCall(
\Drupal::VERSION,
'10.2.0',
fn () => \Drupal\Core\StringTranslation\ByteSizeMarkup::create($file->getSize()),
fn () => format_size($file->getSize()),
);
}
$element['file_' . $file->id()]['filename']['#suffix'] = ' <span class="file-size">(' . $formatted_size . ')</span> ';
$file_variables = array(
'style_name' => $element['#preview_image_style'],
'uri' => $file->getFileUri(),
......
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