• I have decided to update my website [wordpress based], and with that use the bootstrap framework also.

    Now, I can make any image responsive by using the class ‘img-responsive’ .

    Now this is ok for all subsequent posts on my wordpress based site, but what about the 360+ previous posts?

    the images are displayed in the usual manner:

    <img class="style1 style2" ...I did a str_replace on ‘class=”‘

    and replaced it with ‘class=”img-responsive ‘, but this did not make the image responsive, it seems that the img-responsive tag must come after the pre-defined like

    <img class="style1 style2 img-responsive" ...

    Now, the only way I can think to do this is to search the post content for ‘<img ‘, then search for ‘class=”‘, then search for the closing ‘”‘, step back one position and insert the string ‘img-responsive’.

    Now this seems awfully complicated to achieve just adding a class to historical posts, that I now wish to display in a new theme … I feel like I am using a sledgehammer to crack a wallnut.

    Is there any better way than this?

  • The topic ‘WordPress & Bootstrap IMG Class 'fixing'’ is closed to new replies.