Hot answers tagged

2

The Latest Posts block uses (wp.data.select( 'core/block-editor' ).getSettings() to get) the image sizes in the editor settings which can be filtered via the block_editor_settings hook in PHP: apply_filters( 'block_editor_settings', array $editor_settings, WP_Post $post ) Filters the settings to pass to the block editor. And the setting name used for the ...


1

I find the solution using this How to change the markup Wordpress inserts for post images My final code is: add_filter( 'image_send_to_editor', 'add_custom_data_attribute_send_to_editor', 10, 8 ); function add_custom_data_attribute_send_to_editor( $html, $id, $caption, $title, $align, $url, $size, $alt ){ if( $id > 0 ){ $post = get_post( $...


1

You can easily inspect all the metadata for any post like so: // 123 is the (attachment) post ID var_dump( get_post_meta( 123 ) ); And in a default WordPress setup with no plugins or theme which add custom metadata to the image attachment post, the metadata you'd get are: _wp_attached_file — string, the image file (path and name) for the attachment post ...


1

There are many different ways to optimize images. I'd say, if you're not very technical, or just don't have the time or money to spend, I'd recommend trying Jetpack: https://jetpack.com/support/site-accelerator/ It will automatically host your images on their CDN, which is what you were wanting to do. It also serves webp images which are smaller than JPG or ...


1

If you are using bootstrap and want a responsive image in the_content(). You may try this code; works fine in my case img-fluid. You can replace it with your own class. function add_image_responsive_class($content) { global $post; $pattern ="/<img(.*?)class=\"(.*?)\"(.*?)>/i"; $replacement = '<img$1class="$2 ...


Only top voted, non community-wiki answers of a minimum length are eligible