function jhp_gallery_meta_box($post) { $images = jhp_get_gallery_images($post, 150, 150, true); $image_ids = jhp_get_gallery_ids($post); ?> <style> .image-wrapper { text-align: center; display: block; padding: 5px; border: 1px solid #DFDFDF; float: left; margin-right: 7px; margin-bottom: 7px; } .image-wrapper img { display: block; } </style> <p style="display: block; float: right"> <?php tj_register_custom_media_button('jhp_gallery_images', 'Gallery Image', true, true, 150, 150); ?> <a class="add-image button thickbox" onclick="return false;" title="Add Image" href="media-upload.php?button=jhp_gallery_images&multiple=yes&type=image&TB_iframe=true&width=640&height=197"> Add Gallery Image </a> <input type="hidden" name="jhp_gallery_images" id="jhp_gallery_images" value="<?php echo implode(',', jhp_get_gallery_ids($post)); ?> " /> </p> <div style="padding: 0 10px; float: left;" id="jhp_gallery_images_container"> <?php if ($image_ids) { ?> <?php foreach ($image_ids as $id) { ?> <span class="image-wrapper" id="<?php echo $id; ?> "><img src="<?php echo $images[$id]; ?> " /> <a class="delete_custom_image" rel="jhp_gallery_images:<?php echo $id; ?> ">Delete</a> | </span> <?php } ?> <?php } else { ?> <p class="empty-message">No Gallery Images 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 }
function jhp_get_gallery_images($post = null, $w = 0, $h = 0, $crop = false) { if ($post === null) { global $post; } $images = array(); $attachment_ids = jhp_get_gallery_ids($post); if (!$attachment_ids) { return array(); } foreach ($attachment_ids as $id) { $images[$id] = tj_phpthumb_it(get_attached_file($id), $w, $h, $crop); } return $images; }