ID,'_articlephoto_suppress',true);
?>
checked="checked" />
Current Photo
0)
{
$uploaded = wp_handle_upload($_FILES['articlephoto_file'], array('action' => $_POST['action']));
if (!isset($uploaded['error']))
{
delete_post_meta($postid, '_articlephoto_url');
delete_post_meta($postid, '_articlephoto_filename');
add_post_meta($postid, '_articlephoto_url', $uploaded['url']);
add_post_meta($postid, '_articlephoto_filename', $uploaded['file']);
}
}
}
add_action('edit_post', 'articlephoto_upload');
add_action('save_post', 'articlephoto_upload');
// Size = 0 for original, otherwise image width
function get_the_article_photo($size)
{
global $post;
$rawurl = get_post_meta($post->ID, '_articlephoto_url', true);
$rawfile = get_post_meta($post->ID, '_articlephoto_filename', true);
if ($rawurl == '')
{
return FALSE;
}
$image = new Imagick($rawfile);
if ($size == 0 || $size >= $image->getImageWidth())
{
return $rawurl;
}
if (file_exists($rawfile . '-' . $size))
{
return $rawurl . '-' . $size;
}
$image->thumbnailImage($size, 0);
$image->writeImage($rawfile . '-' . $size);
return $rawurl . '-' . $size;
}
function the_article_photo($size)
{
$p = get_the_article_photo($size);
if ($p === FALSE)
{
$p = get_bloginfo('template_directory') . '/img/box.png';
}
echo $p;
}
function get_the_article_photo_caption()
{
global $post;
return get_post_meta($post->ID, '_articlephoto_caption', true);
}
function the_article_photo_caption()
{
echo get_the_article_photo_caption();
}
function get_the_article_img($size)
{
$p = get_the_article_photo($size);
if ($p === false)
{
return '';
}
else
{
$c = get_the_article_photo_caption();
return '
';
}
}
function the_article_img($size)
{
echo get_the_article_img($size);
}
?>