WordPress how to: Set image width / height automatically

If you insert an image into a Worpress post, it sets by default width and height. Sometime you need to autosize images at runtime how you can achieve this?

First step

  1. Remove while you are posting the width and height attributes from the image tag (this sets the image size as it is really)
  2. Resize tag image dynamically using CCS

    .post-content img{
    max-width: 460px;
    width: expression(this.width > 460 ? 460: true);

This allows you  to have auto sized images, but there is a problem… What happens to the old posts? We need to edit all the old posts manually?

You can avoid this activity by introducing a new custom function in your function.php file.

Second step

  1. Edit function.php and define a new function like this

    function remove_width_height($string){
    return preg_replace('/\<(.*?)(width="(.*?)")(.*?)(height="(.*?)")(.*?)\>/i', '<$1$4$7>',$string);

  2. Modify your theme calling this function in your page.php and index.php before writing the post_content.

Enable Gzip compression in WordPress (and not only)

Checking my blog performance I noticed that after the theme upgrade gzip compression is no longer active.

I will give you a easy tutorial in order to enable gzip compression without the installation of any plugins (like cache, super cache and so on) that I really hate.

Continue reading “Enable Gzip compression in WordPress (and not only)”

Multisite on plinky.it

Hi there,

if you tried to access to the blog today, you would notice that it was on maintenance.

After few hours of rework I finally reimplemented the WordPress 3.0 installation in order to activate Multi-site  functionality using the old url pattern.

Thanks for your understanding.

WordPress 2.8 Upgrade

Hi everybody,

today we successfully upgraded to WordPress 2.8, if you find any error or inconsistence please contact me.


Welcome to www.plinky.it

Dear reader,

I’m proud to present you the new Plinky Blog, yesterday we moved to a no-free domain and also upgraded to Worpress 4.7 and Librio 1.0.

Many news are coming, stay tuned!!!

See you very soon again on WWW.PLINKY.IT.