Created
July 13, 2011 07:45
-
-
Save senlin/1079895 to your computer and use it in GitHub Desktop.
show uploaded images on single-customposttype.php file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// use this only for the metabox script of Rilwis - http://www.deluxeblogtips.com/p/meta-box-script-for-wordpress.html#images | |
// the code below shows the image with a link to itself (to be used on thickbox overlays) | |
global $wpdb; | |
$meta = get_post_meta(get_the_ID(), 'sl_screenshots', false); | |
$meta = implode(',', $meta); | |
$images = $wpdb->get_col(" | |
SELECT ID FROM $wpdb->posts | |
WHERE post_type = 'attachment' | |
AND ID in ($meta) | |
ORDER BY 'menu_order' ASC | |
"); | |
foreach ($images as $image) { | |
// get image's source based on size, can be 'thumbnail', 'medium', 'large', 'full' or registered post thumbnails sizes | |
$src = wp_get_attachment_image_src($image, 'thumbnail'); | |
$src = $src[0]; | |
// add additional image source to show full image below | |
$srcfull = wp_get_attachment_image_src($image, 'full'); | |
$srcfull = $srcfull[0]; | |
// show image with link to its full size | |
echo "<a href='$srcfull'><img src='$src' /></a>"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment