Skip to content
Browse files

Merge pull request #471 from IgorCode/trunk

Image preview size for file_list field. Props @IgorCode.
  • Loading branch information...
2 parents 056140d + b1a7975 commit f6876da2a09d2ad0599aa7be16f51f28b4e9bee7 @jtsternberg jtsternberg committed Mar 2, 2014
Showing with 8 additions and 5 deletions.
  1. +5 −4 example-functions.php
  2. +3 −1 helpers/cmb_Meta_Box_types.php
View
9 example-functions.php
@@ -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' ),
View
4 helpers/cmb_Meta_Box_types.php
@@ -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>';

0 comments on commit f6876da

Please sign in to comment.
Something went wrong with that request. Please try again.