Skip to content

Commit

Permalink
Merge pull request #123 from meydjer/master
Browse files Browse the repository at this point in the history
Change $meta order using the posts 'menu_order'
  • Loading branch information
rilwis committed May 11, 2012
2 parents 0eeca2a + cbc8810 commit 75635b0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions inc/fields/image.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@ static function html( $html, $meta, $field )
$html .= "<h4>{$i18n_msg}</h4>";
$html .= "<ul class='rwmb-images rwmb-uploaded'>";

// Change $meta order using the posts 'menu_order'
$meta_menu_order = array();
foreach ($meta as $post_id) {
$post_meta = get_post($post_id);
$meta_menu_order[$post_meta->menu_order] = $post_id;
}
ksort($meta_menu_order);
$meta = $meta_menu_order;

foreach ( $meta as $image )
{
$src = wp_get_attachment_image_src( $image, 'thumbnail' );
Expand Down
9 changes: 9 additions & 0 deletions inc/fields/plupload-image.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,15 @@ static function html( $html, $meta, $field )
if ( ! is_array( $meta ) )
$meta = ( array ) $meta;

// Change $meta order using the posts 'menu_order'
$meta_menu_order = array();
foreach ($meta as $post_id) {
$post_meta = get_post($post_id);
$meta_menu_order[$post_meta->menu_order] = $post_id;
}
ksort($meta_menu_order);
$meta = $meta_menu_order;

$i18n_msg = _x( 'Uploaded files', 'image upload', 'rwmb' );
$i18n_title = _x( 'Upload files', 'image upload', 'rwmb' );

Expand Down

0 comments on commit 75635b0

Please sign in to comment.