hookMethods(); } /** * Registers custom image sizes. * * @hook init * @since 1.0.0 */ public function register(): void { add_image_size( 'anselm-16x9-lg', 2048, 1152, true ); add_image_size( 'anselm-21x9-lg', 2048, 864, true ); add_image_size( 'anselm-9x16-md', 1024, 1820, true ); add_image_size( 'anselm-3x4-md', 1024, 1365, true ); add_image_size( 'anselm-1x1-md', 1024, 1024, true ); } /** * Filters the image size dropdown in the editor so our custom sizes * appear for selection. * * @hook image_size_names_choose * @since 1.0.0 */ public function imageSizeNamesChoose( array $sizes ): array { $sizes[ 'anselm-16x9-lg'] = __( '16:9 (Landscape)', 'anselm' ); $sizes[ 'anselm-21x9-lg'] = __( '21:9 (Landscape)', 'anselm' ); $sizes[ 'anselm-9x16-md'] = __( '9:16 (Portrait)', 'anselm' ); $sizes[ 'anselm-3x4-md'] = __( '3:4 (Portrait)', 'anselm' ); $sizes[ 'anselm-1x1-md'] = __( '1:1 (Square)', 'anselm' ); return $sizes; } /** * Limit the big image threshold to our largest image. * * @hook big_image_size_threshold 5 * @since 1.0.0 */ public function bigImageSizeThreshold( int $threshold ): int { return $this->threshold_width > $threshold ? $this->threshold_width : $threshold; } /** * Sets the default `post-thumbnail` size to a theme-specific size. * * @hook post_thumbnail_size 5 * @since 1.0.0 */ public function postThumbnailSize( string $size ): string { return 'post-thumbnail' === $size ? 'anselm-16x9-lg' : $size; } }