Closed (fixed)
Project:
Gutenberg
Version:
8.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
8 Feb 2023 at 10:21 UTC
Updated:
21 Feb 2025 at 12:49 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #3
fabioneves commentedComment #4
fabioneves commentedAdds an accordion to the "Gutenberg Experience" settings on content type edit screen with an option to filter allowed image styles.
Comment #5
fabioneves commentedAdds missing code to filter image sizes in gutenberg sidebar
Comment #6
fabioneves commentedFixes 'original' being shown when it's not selected in allowed styles
Comment #7
jbaum_13 commentedThanks for working on this! This capability would be great!
I installed the patch #6 and got the following error:
Warning: foreach() argument must be of type array|object, null given in gutenberg_form_alter() (line 281 of /var/www/html/web/modules/contrib/gutenberg/gutenberg.module)
#0 /var/www/html/web/core/includes/bootstrap.inc(347): _drupal_error_handler_real(2, 'foreach() argum...', '/var/www/html/w...', 281)
#1 /var/www/html/web/modules/contrib/gutenberg/gutenberg.module(281): _drupal_error_handler(2, 'foreach() argum...', '/var/www/html/w...', 281)
#2 /var/www/html/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(562): gutenberg_form_alter(Array, Object(Drupal\Core\Form\FormState), 'node_type_edit_...')
#3 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(838): Drupal\Core\Extension\ModuleHandler->alter('form', Array, Object(Drupal\Core\Form\FormState), 'node_type_edit_...')
#4 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(282): Drupal\Core\Form\FormBuilder->prepareForm('node_type_edit_...', Array, Object(Drupal\Core\Form\FormState))
#5 /var/www/html/web/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm(Object(Drupal\node\NodeTypeForm), Object(Drupal\Core\Form\FormState))
#6 [internal function]: Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch))
#7 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#8 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#9 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#10 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#11 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(169): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#12 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#13 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#14 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#15 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#16 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#17 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#18 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#19 /var/www/html/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#20 /var/www/html/web/core/lib/Drupal/Core/DrupalKernel.php(718): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#21 /var/www/html/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#22 {main}
The list to select the image styles did work, and in gutenberg the options are only showing what I chose, but the image style is not being applied when i save the page.
Comment #8
kjankowski commentedAdded a small fix that will prevent showing warnings in the editor whenever a new image style is added.
Comment #9
twiik commentedHere's the patch in #8 rerolled for Gutenberg 3.0.
We've been running that patch for ages now.
Comment #15
marcofernandes commentedFinally merged to 2.x and 3.0.x. Great work y'all 😉
Comment #16
tkiehne commentedJust a notice for anyone who gets a warning message as follows after upgrading to 3.0.3:
You will need to re-save the content type configuration for all content types using Gutenberg to set the allowed styles and clear this warning.
Comment #17
szeidler@tkiehne This has fixed in #3467986: Undefined variable $sizes in gutenberg_form_node_form_alter().
But I have another one as well, if you just updated without saving all node forms again.
So it's actually better to do the following
In addition there is the following:
If the site introduces a new image style after the node form has been saved, this will also lead to a warning.
Comment #19
szeidlerThanks @marcofernandes
Comment #22
leksat commentedThere's a new issue caused by this change: #3471570: Warning: Trying to access array offset on value of type null in gutenberg_form_node_form_alter() (line 578 of gutenberg.module).
I explained my findings here: https://www.drupal.org/project/gutenberg/issues/3471570#comment-15786262
Comment #23
codebymikey commentedFollowing this change, the Original (full) image style is no longer visible in 3.x.