Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

Hook-Element giving error after image size variant php

  • techbackend04

    After I add the below code in the functions.php of child theme NOT to create image variants.

    // Remove all image sizes and srcset on upload
    function remove_all_image_sizes() {
    return array();
    add_filter(‘intermediate_image_sizes’, ‘remove_all_image_sizes’);

    // Remove additional image sizes on upload
    function remove_additional_image_sizes() {
    // remove_image_size(‘custom-size’); // Uncomment and replace ‘custom-size’ with your custom size name if needed
    add_action(‘init’, ‘remove_additional_image_sizes’);

    I am not able to open any Elements. It sends the below error. After I remove the above image size code, the elements works fine.

    Error Details
    An error of type E_ERROR was caused in line 1760 of the file /wp-content/plugins/gp-premium/elements/class-block-elements.php. Error message: Uncaught TypeError: array_merge(): Argument #1 must be of type array, null given in /wp-content/plugins/gp-premium/elements/class-block-elements.php:1760
    Stack trace:
    #0 /wp-content/plugins/gp-premium/elements/class-block-elements.php(1760): array_merge()
    #1 /wp-content/plugins/gp-premium/elements/class-block-elements.php(154): GeneratePress_Block_Elements->get_image_sizes()
    #2 /wp-includes/class-wp-hook.php(324): GeneratePress_Block_Elements->enqueue_assets()
    #3 /wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters()
    #4 /wp-includes/plugin.php(517): WP_Hook->do_action()
    #5 /wp-admin/edit-form-blocks.php(272): do_action()
    #6 /wp-admin/post.php(187): require(‘/home/techback/…’)
    #7 {main}

    Appreciate your support to resolve.


  • Hi there,

    Disable the code first, then check each of the elements if any non-full-size image size is being selected for image blocks.

    As with the code, you only have full-size images available, if you choose other sizes for the images, it will cause errors.

  • techbackend04

    I have only 2 elements, one for the login icon hook and another one for footer.

    Even when I change these elements to draft, still get this error. Also with the image size code, I am unable to create new elements. It just gives the error before going to the draft page.

    If I remove the code, all element and new element creation works.
    In the 2 elements, I do not have any images, just icon svg’s.

    Appreciate your dedicate support.

  • Hi there,

    The error suggests that the function is expecting an array. We can try returning an array with an empty string instead of an empty array. Try this code:

    function remove_all_image_sizes( $default ) {
        $default = array('');
        return $default;
    add_filter('intermediate_image_sizes', 'remove_all_image_sizes');
    // Remove additional image sizes on upload
    function remove_additional_image_sizes() {
        // remove_image_size('custom-size'); // Uncomment and replace 'custom-size' with your custom size name if needed
    add_action('init', 'remove_additional_image_sizes');
  • techbackend04

    Awesome Alvind.

    The above code works fine.
    Thanks for your support.
    Good Luck.

  • No problem!

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.