You appear to be a bot. Output may be restricted
Description
Get best fitting image file name WITHOUT resizing
Usage
$string = bw_get_best_fit( $post_id, $size );
Parameters
- $post_id
- ( mixed ) required –
- $size
- ( mixed ) required –
Returns
string path for the chosed attached image (within wp-uploads)
Source
File name: oik-nivo-slider/nivo.php
Lines:
1 to 41 of 41
function bw_get_best_fit( $post_id, $size ) { $image = null; $metadata = get_post_meta( $post_id, "_wp_attachment_metadata", false ); bw_trace2( $metadata, "metadata" ); if ( $metadata ) { $first = bw_array_get( $metadata, 0, null ); if ( $first ) { $file = bw_array_get( $first, "file", null ); if ( $file ) { $sizes = bw_array_get( $first, "sizes", null ); //bw_trace2( $sizes, "sizes", false ); if ( $sizes ) { if ( !is_array( $size ) ) { $images = bw_array_get( $sizes, $size, null ); //bw_trace2( $images, "images", false ); if ( $images ) { $image = bw_array_get( $images, "file", null ); } else { $image = pathinfo( $file, PATHINFO_BASENAME ); } } else { $sizes[ 'full' ] = array( "file" => pathinfo( $file, PATHINFO_BASENAME ) , "width" => bw_array_get( $first, "width", 0 ) , "height" => bw_array_get( $first, "height", 0 ) ); $image = bw_get_by_size( $sizes, $size ); //bw_trace2( $image, "image by_size", false ); } } else { $image = pathinfo( $file, PATHINFO_BASENAME ); } if ( $image ) { $image = pathinfo( $file, PATHINFO_DIRNAME ) . '/' . $image; //bw_trace2( $image, "image with PATHINFO", false ); } } } } return( $image ); }