Skip to content

Commit

Permalink
fixes crowdfavorite#8, no longer rely on shortcode for gallery in admin
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkingorg committed Jan 5, 2012
1 parent 25f897f commit 9eca953
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
5 changes: 4 additions & 1 deletion cf-post-formats.php
Expand Up @@ -187,8 +187,11 @@ function cfpf_format_audio_save_post($post_id) {
// action added in cfpf_admin_init()

function cfpf_gallery_preview() {
if (empty($_POST['id']) && !($post_id = intval($_POST['id']))) {
exit;
}
global $post;
$post->ID = intval($_POST['id']);
$post->ID = $post_id;
ob_start();
include('views/format-gallery.php');
$html = ob_get_clean();
Expand Down
13 changes: 7 additions & 6 deletions css/admin.css
Expand Up @@ -71,16 +71,17 @@
padding: 0;
}
.cp-elm-block .cp-elm-container .gallery {
margin: 0;
padding-bottom: 8px;
}
.cp-elm-block .cp-elm-container .gallery dl,
.cp-elm-block .cp-elm-container .gallery dt {
display: inline;
}
.cp-elm-block .cp-elm-image-gallery dt {
margin: 0 5px 5px 0;
.cp-elm-block .cp-elm-container .gallery li {
display: inline-block;
margin: 0 8px 8px 0;
padding: 0;
}
.cp-elm-block .cp-elm-container .gallery li img {
vertical-align: middle;
}

/* Video Field */
#cfpf-format-video-embed {
Expand Down
18 changes: 17 additions & 1 deletion views/format-gallery.php
Expand Up @@ -3,7 +3,23 @@
<div class="cp-elm-container">

<?php
echo do_shortcode('[gallery columns="9999"]');

// running this in the view so it can be used by multiple functions

$attachments = get_posts(array(
'post_type' => 'attachment',
'numberposts' => -1,
'post_status' => null,
'post_parent' => $post->ID
));
if ($attachments) {
echo '<ul class="gallery">';
foreach ($attachments as $attachment) {
echo '<li>'.wp_get_attachment_image($attachment->ID, 'thumbnail').'</li>';
}
echo '</ul>';
}

?>
<p class="none"><a href="#" class="button"><?php _e('Upload Images', 'cf-post-format'); ?></a></p>
</div>
Expand Down

0 comments on commit 9eca953

Please sign in to comment.