Description
Load the saved mshot image if it already existsIf we hve previously saved this image then the value for '_wp_attached_file' may contain a modified version of the original file name. At the front will be the prefix for uploaded files and at the end the filename may have had some additional characters added to make it unique. So, http://herbmiller.me/about/site-history will get created as mshot-herbmiller.me-about-site-history.jpg when first saved giving a file name of 2013/10/mshot-herbmiller.me-about-site-history.jpg BUT if saved multiple times (why would that be ?) then a suffix is added before the file extension e.g.
Usage
oikms_load_attachment( $atts );Parameters
- $atts
- ( mixed ) required –
Returns
voidSource
File name: oik-mshot/shortcodes/oik-mshot.phpLines:
1 to 26 of 26
function oikms_load_attachment( $atts ) { $filename = oikms_create_attachment_filename( $atts ); $filename = str_replace( ".jpg", "", $filename ); $args = array(); $args['post_type'] = "attachment"; // $args['numberposts'] = 1; $args['orderby'] = "date"; $args['order'] = "DESC"; $args['post_status'] = 'inherit'; //$args['name'] = $filename; $args['post_parent'] = 0; $args['meta_key'] = "_wp_attached_file"; $args['meta_compare'] = "LIKE"; $args['meta_value'] = $filename; oik_require( "includes/bw_posts.inc" ); $posts = bw_get_posts( $args ); if ( $posts ) { $id = $posts[0]->ID; // $image = bw_thumbnail( $id, "full", true ); p( "attachment $id" ); $image = $posts[0]->guid; } else { $image = null; } return( $image ); }View on GitHub
Invoked by
Calls
1 to 2 of 2
Call hooks
API Letters:
