Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion inc/Services/Theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ public function after_setup_theme(): void {
*/
$this->add_theme_supports();
$this->remove_theme_supports();
$this->add_images_sizes();

/**
* Load images sizes in Gutenberg.
*/
add_filter( 'image_size_names_choose', [ $this, 'image_size_names_choose' ] );

/**
* Load translations.
Expand Down Expand Up @@ -71,6 +77,31 @@ private function remove_theme_supports(): void {
*/
private function i18n(): void {
// Load theme texdomain
load_theme_textdomain( 'framework-textdomain', \get_theme_file_path( '/languages' ) );
load_theme_textdomain( 'beapi-frontend-framework', \get_theme_file_path( '/languages' ) );
}

/**
* Add images sizes for Gutenberg
*/
private function add_images_sizes(): void {
add_image_size( 'landscape', 600, 400, true );
add_image_size( 'landscape-2x', 1200, 800, true );
}

/**
* Display custom image sizes in Gutenberg
* If you use the WP-THUMB plugin, force to Generate this images (bypass the bea-wp-thumb mu-plugin to restart the generation)
*
* @param array $sizes
*
* @return array
*/
public function image_size_names_choose( array $sizes ): array {
return array_merge(
$sizes,
[
'landscape' => __( 'Landscape - 600 x 400', 'beapi-frontend-framework' ),
]
);
}
}
Loading