Good Ideas

Image Extractor

Posted by:

|

On:

|

Image extractor - plugin per wordpress
Image Extractor is a WordPress plugin that extract the first image from the post and display it. The "Image Extractor" main feature is the capability to resize the image found to a wanted size. The final image is cached in a folder, so you can obtain better performances.

How to install

  • Download the .zip file and extract it
  • Upload the extrated folder (imageExtractor/) to the WordPress plugins folder (wp-content/plugins/)
  • Configure the imageExtractor.php file and set the right cache folder. Make sure it’s writable.
  • Activate the plugin from the WordPress back office panel

How to use

Image Extractor will enable a new template function. It output a complete IMG tag to be inserted into your HTML code. The image source is retrieved from the first image found in the current post. Here is an example showing you how to use it:

<?php
  while (have_posts()) : the_post();
    image_extractor(true, 1, 395, 0, '', '', '<div>', '</div>');
    the_excerpt();
  endwhile;
?>

The syntax is:

  image_extractor($resize=false, $resize_type=1, $width='', $height='', $class='', $id='', $prefix='', $suffix='')

where:

  • resize: indicate if the plugin has to resize the image and store it in the cache folder
  • resize_type: there are 3 type of resizing:
    • 0 -> image will be resized to the new output size, regardless of the original aspectratio. (default)
    • 1 -> image will be cropped if necessary to preserve the aspectratio and avoid image distortions.
    • 2 -> image will be resized preserving its original aspectratio. differences to the new outputsize will be filled with white
  • width: the destination width. If resize is false, this property only add/change the WIDTH attribute of the IMG tag
  • height: the destination height. If resize is false, this property only add/change the HEIGHT attribute of the IMG tag
  • class: add or change the CLASS attribute of the IMG tag
  • id: add or change the ID attribute of the IMG tag
  • prefix: add a prefix to the resulting IMG tag
  • suffix: append a suffix to the resulting IMG tag

The resulting effect is cool! You can resize the post dimension as you want! Here is a screenshot!
PS: Wowww, WordPress staff has just approved my first plugin!!! I’m very very happy. You can find "Image Extractor" on the official WordPress plugin repository.resulting-effect-image-extractor