Пример #1
0
function jhp_main_image_meta_box($post)
{
    $image = jhp_get_main_image($post, 150, 150, true);
    $id = jhp_get_main_image_id($post);
    ?>
	<p style="display: block; float: right">
		<?php 
    tj_register_custom_media_button('jhp_main_image', 'Main Image', true, false, 150, 150);
    ?>
		<a class="add-image button thickbox" onclick="return false;" title="Add Image" href="media-upload.php?button=jhp_main_image&amp;type=image&amp;TB_iframe=true&amp;width=640&amp;height=197">
			<?php 
    echo $image ? 'Change' : 'Add';
    ?>
 Main Image
		</a>
		<input type="hidden" name="jhp_main_image" id="jhp_main_image" value="<?php 
    echo jhp_get_main_image_id($post);
    ?>
" />
	</p>
	
	<div style="padding: 0 10px; float: left;" id="jhp_main_image_container">
		<?php 
    if ($image) {
        ?>
			<span class="image-wrapper" id="<?php 
        echo $id;
        ?>
"><img src="<?php 
        echo $image;
        ?>
" />
			<a class="delete_custom_image" rel="jhp_main_image:<?php 
        echo $id;
        ?>
">Delete</a> | </span>
		<?php 
    } else {
        ?>
			<p class="empty-message">No Main Image Added <?php 
        if ($url = jhp_get_url($post)) {
            ?>
| <a href="<?php 
            echo $url;
            ?>
" target="_blank">Screenshot your site now</a><?php 
        }
        ?>
</p>
		<?php 
    }
    ?>
	</div>
	<div style="clear: both;" /></div>
	<?php 
}
Пример #2
0
function jhp_get_main_image($post = null, $w = 0, $h = 0, $crop = false)
{
    if ($post === null) {
        global $post;
    }
    $attachment_id = jhp_get_main_image_id($post);
    if (!$attachment_id) {
        return null;
    }
    return tj_phpthumb_it(get_attached_file($attachment_id), $w, $h, $crop);
}