• As described in the topic, I have a multisite wordpress and I would like to do the following. For presentation issues I have to set the width of existing images to 100% (If there’s no solution, I can do it manually). Yet, the predefined width/height of the images is taken. Furthermore, I would like to set the image width of newly added images to 100% right away.

    Due to the cascades external CSS-files won’t work. I would rather refrain from using JS to achieve my goals. Any suggestions?

Viewing 2 replies - 1 through 2 (of 2 total)
  • You could always use a filter on the content images

    //will filter only newly added images
    add_filter( 'image_send_to_editor', 'remove_thumbnail_dimensions', 10 );
        function remove_thumbnail_dimensions( $html ) {
                $html = preg_replace( '/(width|height)=\"\d*\"\s/', "", $html );
                return $html;
        }

    The code above suppress the sizes when sent to the editor. (ie) sizes won’t be in post content.

    This bit below will filter the sizes before display. (ie) The sizes are saved to the post but will be filtered before display. This is useful for previous posts.

    add_filter( 'the_content', 'remove_thumbnail_dimensions', 10 );

    Thread Starter HansiZ

    (@hansiz)

    dfunkydog, thank you for your answer. This worked well for images that I upload to the webserver.
    I just noticed, there’s a different kind of images, namely images I include via link. Do you know about an appropriate hook I could use to set the width/height of the image?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Set width of every image from multiple sites to width=100%’ is closed to new replies.