Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1480927

    Hi,
    I registered a custom image size adding following code to functions.php:

    function add_custom_image_size() {
        add_image_size( 'medium_squared', 600, 600, true ); // true = crop esatto
    }
    add_action( 'init', 'add_custom_image_size' );
    
    function add_custom_image_sizes_to_editor( $sizes ) {
    	return array_merge( $sizes, array(
    		'medium_squared' => __( 'Medium squared' ),
    	) );
    }
    add_filter( 'image_size_names_choose', 'add_custom_image_sizes_to_editor' );

    Now I can see and use my new image size in Wp:

    View post on imgur.com

    But i can’t see it in Enfold ALB elemnts dropdowns:

    View post on imgur.com

    Any help?
    Thank you

    #1480970

    Hey aledef,

    Thank you for the inquiry.

    You have to add the image size using the avf_modify_selectable_image_sizes filter.

    Example:

    function avf_modify_selectable_image_sizes_mod( array $selectableImgSize, array $imgSizes ) 
    {
        $selectableImgSize['medium_squared'] = 'Medium squared';
        return $selectableImgSize;
    }
    
    add_filter( 'avf_modify_selectable_image_sizes', 'avf_modify_selectable_image_sizes_mod', 10, 2 );
    

    Let us know if this works.

    Best regards,
    Ismael

    #1481136

    Hi Ismael,
    it works but I had to make a little change to my code.

    Here is the full working code to add custom image sizes to WP and enable them in Enfold ALB, in case anybody needs it:

    // Add image sizes to WP
    function add_custom_image_size() {
        // add_image_size( 'name', width, height, crop );
        add_image_size( 'medium_squared', 600, 600, true );
    }
    add_action( 'after_setup_theme', 'add_custom_image_size' );
    
    // Make custom image sizes selectable from WP admin
    function add_custom_image_sizes_to_editor( $sizes ) {
    	return array_merge( $sizes, array(
    		'medium_squared' => 'Medium squared',
    	) );
    }
    add_filter( 'image_size_names_choose', 'add_custom_image_sizes_to_editor' );
    
    // Make custom image sizes selectable from Enfold ALB elements
    function add_custom_image_sizes_to_enfold_alb( array $selectableImgSize, array $imgSizes ) {
        $selectableImgSize['medium_squared'] = 'Medium squared';
        return $selectableImgSize;
    }
    add_filter( 'avf_modify_selectable_image_sizes', 'add_custom_image_sizes_to_enfold_alb', 10, 2 );

    Thanks

    Best regards,
    Alessio

    #1481146

    Hi,

    Great, I’m glad that you found a solution and thanks for sharing. Please let us know if you should need any further help on the topic, or if we can close it.

    Best regards,
    Rikard

    #1481186

    Hi,
    you can close the topic.

    Best regards,
    Alessio

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Add custom image size to enfold ALB elements’ is closed to new replies.