Skip to content

t-hamano/enable-responsive-image

Repository files navigation

Enable Responsive Image

Test

Test and Deploy

WordPress plugin that adds settings to the Image block to display different images depending on the width of the screen.

Screenshot

Settings added to the block sidebar of the image block

How the image changes depending on the screen width

How to build

npm install
npm run build

Filters

enable_responsive_image_default_media_value( $media_value )

Filters the default media value (px).

Parameters

  • $media_value

    (int) The media value (px). Default is 600.

Example

function custom_enable_responsive_image_default_media_value( $default_media_value ) {
	// Override default media value.
	return 400;
}
add_filter( 'enable_responsive_image_default_media_value', 'custom_enable_responsive_image_default_media_value' );

enable_responsive_image_show_preview_button( $show_preview_button )

Filters whether the preview button is displayed on the block toolbar.

Parameters

  • $show_preview_button

    (boolean) Whether the preview button is displayed on the block toolbar. Default is true.

Example

// Disable the preview button.
add_filter( 'enable_responsive_image_show_preview_button', '__return_false' );

Resources

Image for screenshot

Author

Aki Hamano (Github)