Last active
January 7, 2021 11:53
-
-
Save mklasen/c74c63062023e18369866223d0af643c to your computer and use it in GitHub Desktop.
WordPress: Add image size to block editor settings (ex: Media & Text block)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Main { | |
public function __construct() { | |
$this->init(); | |
} | |
public function init() { | |
add_action( 'after_setup_theme', array( $this, 'add_image_sizes' ) ); | |
add_filter( 'image_size_names_choose', array( $this, 'show_image_sizes' ) ); | |
} | |
public function add_image_sizes() { | |
add_image_size( 'custom-logo', 220, 180, true ); | |
} | |
public function show_image_sizes() { | |
$sizes['custom-logo'] = __( 'Custom logo' ); | |
return $sizes; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment