Themify_image Function

Themify_image() function helps generate a dynamic image with the thumbnail generator (themify/img.php). It can be used inside or outside the WordPress Loop.

Use outside the Loop

You can use the themify_image function outside the Loop to generate a thumbnail image.

<?php themify_image("src=image.jpg&w=200&h=150&alt=Image Description&class=feature-img&before=<p>&after=</p>"); ?>

The code will output:

<p><img src="your_theme/themify/img.php?src=image.jpg&w=200&h=150" alt="Image Description" class="feature-img" /></p>

Use inside the Loop

When the themify_image function is used inside the Loop, you don't need to specify the src parameter. It will automatically look for the custom fields in the following hiearchy order: feature_image, post_image, image, wp_post_thumbnail, and the first image tag in the content.

Note: If there is no image found the function will automatically check for a Youtube or Vimeo embeded video and output the proper video image from the post content. This only happens within the loop and if no "field_name" was specified.

The code below will get the custom field and return the image tag if there is any. The setting parameter is the name that we use in the framework for the width and height setting. If there is no width or height specified in the framework, it will return the w & h parameters (in this case, it is 120 x 60).

<?php if(have_posts() ) : while( has_posts() ) : the_post(); ?>
        
  <?php themify_image("setting=image_post&w=120&h=60"); ?></p>
   
<?php endwhile; endif; ?>

If you want to look for a specific custom field image, add the field_name parameter. You can add multiple fields that will check, in order, until an image is found and returned using commas to separate. The code below will look for: feature_image, post_image, and wp post thumbnail. If there is nothing found in the custom fields or wp post thumbnail, it will not echo the image tag.

<?php if(have_posts() ) : while( has_posts() ) : the_post(); ?>
        
   	<?php themify_image("field_name=feature_image, post_image, wp_thumb&w=60&h=120"); ?></p>
   
	<?php endwhile; endif; ?>

Themify_get_image()

Works the exact same as the themify_image() function except that instead of echoing the string it returns the value. This is best used when storing the value in variables.

<?php themify_get_image(); ?>

Parameters

  • field_name
    (default: looks for feature_image, post_image, image, wp post thumbnail, and the image tag in the content)
    A custom post field name OR comma seperated list of custom field names to be used when looking for the image (Note: only works in the loop)

  • setting
    The image setting id that use in the framework.

  • w
    (default: the image width)
    The fallback/default width of the image if there isn't a width set in the framework settings.

  • h
    (default: the image height)
    The fallback/default height of the image if there isn't a height set in the framework settings.

  • before
    (default: none)
    String or code outputted before the image tag. Will not be returned if there is no image found.

  • after
    (default: none)
    String or code outputted after the image tag. Will not be returned if there is no image found.

  • src
    (default: none)
    Specific url to image. If used in the Loop, you don't need to specify the src.

  • alt
    (default: none/the post title)
    String to be used as the "alt" attribute for the returned image tag. If used in the Loop, it will echo the post title.

  • class
    (default: none)
    String to be used as the "class" attribute for the returned image tag.

  • id
    (default: none)
    String to be used as the "id" attribute for the returned image tag.

Own the Online World with the New Ultra Games Skin + Get 50% OFF Ultra with code GAMES!