The MU forums have moved to WordPress.org

Easy way to wrap text around images (7 posts)

  1. gsxtasy
    Member
    Posted 15 years ago #

    The main purpose of our company using Wordpress MU is for the ease of use for all people posting pages and posts. Is there an easy way to wrap text around images without editing any css or html? We need to make it easy for all authors to wrap the text around the images...they know nothing about html or css

  2. ninjanuts
    Member
    Posted 15 years ago #

    Hi gsxtasy

    Your best bet is probably to write your own plugin that searches for images and replaces some inline styling when it finds them.

    function wrapimages ($content)
    {   
    
    	$img_pattern = '/<img(.*?)\/>/i';
    	$img_replacement = '<img style="float:left;"$1\/>';
    	$content = preg_replace($img_pattern, $img_replacement, $content);
    
    	return $content;
    
    }
    
    add_filter('the_content', 'wrapimages');

    the above is very crude but it's how i'd start off i guess.

  3. cafespain
    Member
    Posted 15 years ago #

    Or just get them to click the left-align or right-align button on the editor when they add an image.

  4. andrea_r
    Moderator
    Posted 15 years ago #

    Or pick themes that have it already written in the css file.

  5. d_kc
    Member
    Posted 15 years ago #

    And if the theme doesnt wrap the images add this to it's css:

    .aligncenter,
    div.aligncenter {
       display: block;
       margin-left: auto;
       margin-right: auto;
    }
    
    .alignleft {
       float: left;
    }
    
    .alignright {
       float: right;
    }
  6. gsxtasy
    Member
    Posted 15 years ago #

    Thanks for all your help...I have added that css code into the style.css file and I clicked align right on the image but its still not wrapping...any other suggestions?

  7. d_kc
    Member
    Posted 15 years ago #

    Look at the default theme's css and copy that.

About this Topic