Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter( 'post_thumbnail_html', 'nelioefi_replace_thumbnail', 10, 5 );
- function nelioefi_replace_thumbnail( $html, $post_id, $post_image_id, $size, $attr ) {
- if ( uses_nelioefi( $post_id ) ) {
- $image_url = get_post_meta( $post_id, '_nelioefi_url', true );
- global $_wp_additional_image_sizes;
- if ( is_array( $size ) ) {
- $width = $size[0];
- $height = $size[1];
- }
- else if ( isset( $_wp_additional_image_sizes[ $size ] ) ) {
- $width = $_wp_additional_image_sizes[ $size ]['width'];
- $height = $_wp_additional_image_sizes[ $size ]['height'];
- }
- $replaced_image = str_replace("/s0/", "/w".$width."-h".$height."-c/", "$image_url");
- $html = sprintf(' <img src="%s"> ', $replaced_image);
- }
- return $html;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement