ID, 'image_tag', true); $args = array( 'order' => 'ASC', 'post_type' => 'attachment', 'post_parent' => get_the_ID(), 'post_mime_type' => 'image', 'post_status' => null, 'numberposts' => 1, ); $attachments = get_posts($args); if ($attachments) { foreach ($attachments as $attachment) { ?>
ID, $autofocus_size); ?>
"; } endif; } /** * Store Images URLS and tags for posts without attachments * - Saves data as custom field */ function autofocus_entry_image_setup($postid) { global $post; $post = get_post($postid); // get url if ( !preg_match('/]*)src=(\"|\')(.+?)(\2)([^>\/]*)\/*>/', $post->post_content, $matches) ) { return false; } // url setup /**/ $post->image_url = $matches[3]; if ( !$post->image_url = preg_replace('/\?w\=[0-9]+/','', $post->image_url) ) return false; $post->image_url = esc_url( $post->image_url, 'raw' ); delete_post_meta($post->ID, 'image_url'); delete_post_meta($post->ID, 'image_tag'); add_post_meta($post->ID, 'image_url', $post->image_url); add_post_meta($post->ID, 'image_tag', ''); } add_action('publish_post', 'autofocus_entry_image_setup'); add_action('publish_page', 'autofocus_entry_image_setup'); /** * Image Author/Credit Display */ function autofocus_image_credit() { global $post; if ( get_the_author_meta('user_url') == '' ) { ?>
© .
© .
0 ) { $display_shutterspeed_meta = "1/" . 1 / $shutterspeed_meta; } else { $display_shutterspeed_meta = 0; } // Start to display EXIF and IPTC data of digital photograph echo '

' . __('Exif Data', 'autofocus') . '

'; echo ''; } /** * Get the Post Thumbnail URL for the EXIF link */ function autofocus_exif_link( $post_id = NULL, $size = 'full-post-thumbnail', $attr = '' ) { global $id; $post_id = ( NULL === $post_id ) ? $id : $post_id; $post_thumbnail_id = get_post_thumbnail_id( $post_id ); $size = apply_filters( 'full-post-thumbnail', $size ); if ( $post_thumbnail_id ) { $thumburl = get_attachment_link( $post_thumbnail_id, $size, false, $attr ); } else { $thumburl = ''; } return $thumburl; } /** * Add Images/Video/Embeds to feeds * * - Based on the Custom Fields for Feeds Plugin by Justin Tadlock: * - http://justintadlock.com/archives/2008/01/27/custom-fields-for-feeds-wordpress-plugin */ function autofocus_feed_content( $content ) { global $post, $id; $blog_key = substr( md5( get_home_url('url') ), 0, 16 ); if ( !is_feed() ) return $content; // If there's no video is there an image thumbnail? if ( has_post_thumbnail() ) { $mediafeed = the_post_thumbnail('medium'); } // If there's a video or an image, display the media with the content if ($mediafeed !== '') { $content = '

' . $mediafeed . '


' . $content; return $content; // If there's no media, just display the content } else { $content = $content; return $content; } } add_filter('the_content', 'autofocus_feed_content'); ?>