certainlyakey
6/23/2014 - 1:04 PM

Link single images to image files' large versions instead of full - Wordpress function

Link single images to image files' large versions instead of full - Wordpress function

<?php
//Function to link SINGLE images to large versions instead of originals. From here http://posterous.jefflundberg.com/make-wordpress-image-link-to-large-image-inst, used on Moscovita.it
add_filter('attachment_fields_to_edit',  'large_attachment_fields_to_edit', 0,  2);
function large_attachment_fields_to_edit($fields, $post){
  if (substr($post->post_mime_type,0,5) == 'image'){
    $html = "<input type='text' class='text urlfield' name='attachments[$post->ID][url]' value='" . esc_attr(array_shift( wp_get_attachment_image_src($post->ID, 'large', false) )) . "' /><br />
      <button type='button' class='button urlnone' title=''>" . __('None') . "</button>
      <button type='button' class='button urlfile' title='".esc_attr(array_shift( wp_get_attachment_image_src($post->ID, 'large', false) ))."'>Large File URL</button>
      <button type='button' class='button urlfile' title='" . esc_attr(wp_get_attachment_url($post->ID)) . "'>" . __('Original File URL') . "</button>
      <button type='button' class='button urlpost' title='" . esc_attr(get_attachment_link($post->ID)) . "'>" . __('Post URL') . "</button>
";
                $fields['url']['html'] = $html;
        }
        return $fields;
}
?>