Skip to content
This repository has been archived by the owner on Dec 17, 2018. It is now read-only.

Commit

Permalink
Merge pull request #471 from IgorCode/trunk
Browse files Browse the repository at this point in the history
Image preview size for file_list field. Props @IgorCode.
  • Loading branch information
jtsternberg committed Mar 2, 2014
2 parents 056140d + b1a7975 commit f6876da
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 5 additions & 4 deletions example-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,11 @@ function cmb_sample_metaboxes( array $meta_boxes ) {
'type' => 'file',
),
array(
'name' => __( 'Multiple Files', 'cmb' ),
'desc' => __( 'Upload or add multiple images/attachments.', 'cmb' ),
'id' => $prefix . 'test_file_list',
'type' => 'file_list',
'name' => __( 'Multiple Files', 'cmb' ),
'desc' => __( 'Upload or add multiple images/attachments.', 'cmb' ),
'id' => $prefix . 'test_file_list',
'type' => 'file_list',
'preview_size' => array( 100, 100 ), // Default: array( 50, 50 )
),
array(
'name' => __( 'oEmbed', 'cmb' ),
Expand Down
4 changes: 3 additions & 1 deletion helpers/cmb_Meta_Box_types.php
Original file line number Diff line number Diff line change
Expand Up @@ -520,11 +520,13 @@ public static function file_list( $field, $meta, $object_id ) {

if ( $meta && is_array( $meta ) ) {

$preview_size = empty( $field['preview_size'] ) ? array( 50, 50 ) : $field['preview_size'];

foreach ( $meta as $id => $fullurl ) {
if ( self::is_valid_img_ext( $fullurl ) ) {
echo
'<li class="img_status">',
wp_get_attachment_image( $id, array( 50, 50 ) ),
wp_get_attachment_image( $id, $preview_size ),
'<p><a href="#" class="cmb_remove_file_button">'. __( 'Remove Image', 'cmb' ) .'</a></p>
<input type="hidden" id="filelist-', $id ,'" name="', $field['id'] ,'[', $id ,']" value="', $fullurl ,'" />
</li>';
Expand Down

0 comments on commit f6876da

Please sign in to comment.