daily pastebin goal
28%
SHARE
TWEET

Untitled

a guest Sep 28th, 2014 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. add_filter( 'post_thumbnail_html', 'nelioefi_replace_thumbnail', 10, 5 );
  2. function nelioefi_replace_thumbnail( $html, $post_id, $post_image_id, $size, $attr ) {
  3.         if ( uses_nelioefi( $post_id ) ) {
  4.                 $image_url = get_post_meta( $post_id, '_nelioefi_url', true );
  5.                 global $_wp_additional_image_sizes;
  6.  
  7.                 if ( is_array( $size ) ) {
  8.                         $width = $size[0];
  9.                         $height = $size[1];
  10.                 }
  11.                 else if ( isset( $_wp_additional_image_sizes[ $size ] ) ) {
  12.                         $width = $_wp_additional_image_sizes[ $size ]['width'];
  13.                         $height = $_wp_additional_image_sizes[ $size ]['height'];
  14.                 }
  15.                
  16.                 $replaced_image = str_replace("/s0/", "/w".$width."-h".$height."-c/", "$image_url");
  17.                 $html = sprintf(' <img src="%s"> ', $replaced_image);
  18.                 }
  19.         return $html;
  20. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top