Plugin Directory

Changeset 1210231


Ignore:
Timestamp:
07/31/2015 09:20:08 AM (11 years ago)
Author:
phuisman
Message:

Added feature so that you can control the amount of images that will be loaded in a photoset

Location:
flickr-field-for-advanced-custom-fields/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • flickr-field-for-advanced-custom-fields/trunk/acf-flickr-v4.php

    r1208950 r1210231  
    2424        $this->category = __("Content", 'acf'); // Basic, Content, Choice, etc
    2525        $this->defaults = array(
    26             // add default here to merge into your field.
     26            // add defaults here to merge into your field.
    2727            'flickr_api_key'        => '',
    2828            'flickr_user_id'        => '',
     
    3232            'flickr_thumb_size'     => 'square',
    3333            'flickr_large_size'     => 'large_1024',
     34            'flickr_show_limit'     => '500',
    3435            'flickr_cache_enabled'  => '1',
    3536            'flickr_cache_duration' => '168',
     
    128129            <td class="label">
    129130                <label><?php _e( 'Display amount', 'acf-flickr' );?></label>
    130                 <p class="description"><?php _e('How many sets/photos do you want to select from? The most recent items will be shown first.', 'acf-flickr');?></p>
     131                <p class="description"><?php _e('How many sets/photos do you want the admin to select from? The most recent items will be shown first.', 'acf-flickr');?></p>
    131132            </td>
    132133            <td>
     
    152153            <td class="label">
    153154                <label><?php _e( 'Max selectable amount', 'acf-flickr' );?></label>
    154                 <p class="description"><?php _e('What\'s the maximum amount to be attached to a post? Using 0 is default (and unlimited).', 'acf-flickr');?></p>
     155                <p class="description"><?php _e('What\'s the maximum amount to be attached to a post by the user? Using 0 is default (and unlimited).', 'acf-flickr');?></p>
    155156            </td>
    156157            <td>
     
    250251                        'original'     => 'Original',
    251252                    )
     253                ));
     254                ?>
     255           </td>
     256        </tr>
     257        <tr class="field_option field_option_<?php echo $this->name; ?>">
     258            <td class="label">
     259                <label><?php _e( 'Maximum amount of photos in the set to load', 'acf-flickr' );?></label>
     260                <p class="description"><?php _e('For sets only: How many photos should be loaded when viewing the set? Flickr allows a maximum of 500.', 'acf-flickr');?></p>
     261            </td>
     262            <td>
     263                <?php
     264                do_action('acf/create_field', array(
     265                    'type'  =>  'text',
     266                    'name'  =>  'fields['.$key.'][flickr_show_limit]',
     267                    'value' =>  $field['flickr_show_limit'],
    252268                ));
    253269                ?>
     
    541557        $data = array();
    542558
    543         $data['items']      = $value;
    544         $data['type']       = $field['flickr_content_type'];
    545         $data['thumb_size'] = $field['flickr_thumb_size'];
    546         $data['large_size'] = $field['flickr_large_size'];
    547         $data['user_id']    = $field['flickr_user_id'];
    548         $data['api_key']    = $field['flickr_api_key'];
     559        $data['items']             = $value;
     560        $data['type']              = $field['flickr_content_type'];
     561        $data['flickr_show_limit'] = $field['flickr_show_limit'];
     562        $data['thumb_size']        = $field['flickr_thumb_size'];
     563        $data['large_size']        = $field['flickr_large_size'];
     564        $data['user_id']           = $field['flickr_user_id'];
     565        $data['api_key']           = $field['flickr_api_key'];
    549566
    550567        return $data;
     
    585602
    586603            if ($value['type'] == 'sets' || $value['type'] == 'galleries') {
     604                // Set default to get if flickr_show_limit does not exist
     605                if(!isset($value['flickr_show_limit'])) {
     606                    $value['flickr_show_limit'] = '500';
     607                }
     608
    587609                // Get photos from Flickr based on set/gallery id
    588610                $sets = array();
    589611                foreach($value['items'] as $id) {
    590612                    if ($value['type'] == 'sets') {
    591                         $photos = $f->photosets_getPhotos($id, 'url_o');
     613                        $photos = $f->photosets_getPhotos($id, 'url_o', null, $value['flickr_show_limit']);
    592614                        $name = 'photoset';
    593615                    }
    594616                    elseif ($value['type'] == 'galleries') {
    595                         $photos = $f->galleries_getPhotos($id, 'url_o');
     617                        $photos = $f->galleries_getPhotos($id, 'url_o', $value['flickr_show_limit']);
    596618                        $name = 'photos';
    597619                    }
  • flickr-field-for-advanced-custom-fields/trunk/acf-flickr-v5.php

    r1208950 r1210231  
    4949            'flickr_sets_amount'    => '9999',
    5050            'flickr_max_selected'   => '0',
     51            'flickr_show_limit'     => '500',
    5152            'flickr_thumb_size'     => 'square',
    5253            'flickr_large_size'     => 'large_1024',
     
    107108        acf_render_field_setting( $field, array(
    108109            'label'        => __('Display amount','acf-flickr'),
    109             'instructions' => __('How many sets/photos do you want to select from? The most recent items will be shown first.','acf-flickr'),
     110            'instructions' => __('How many sets/photos do you want the admin to select from? The most recent items will be shown first.','acf-flickr'),
    110111            'type'         => 'select',
    111112            'name'         => 'flickr_sets_amount',
     
    123124        acf_render_field_setting( $field, array(
    124125            'label'        => __('Max selectable amount','acf-flickr'),
    125             'instructions' => __('What\'s the maximum amount to be attached to a post? Using 0 is default (and unlimited).','acf-flickr'),
     126            'instructions' => __('What\'s the maximum amount to be attached to a post by the user? Using 0 is default (and unlimited).','acf-flickr'),
    126127            'type'         => 'text',
    127128            'name'         => 'flickr_max_selected',
     
    153154            'name'         => 'flickr_cache_duration',
    154155            'append'       => 'minutes',
     156        ));
     157
     158        acf_render_field_setting( $field, array(
     159            'label'        => __('Maximum amount of photos in the set to load', 'acf-flickr'),
     160            'instructions' => __('For sets only: How many photos should be loaded when viewing the set? Flickr allows a maximum of 500.', 'acf-flickr'),
     161            'type'         => 'text',
     162            'name'         => 'flickr_show_limit',
    155163        ));
    156164
     
    183191        ));
    184192
    185 
    186 
    187     }
    188 
     193    }
    189194
    190195
     
    526531        $data = array();
    527532
    528         $data['items']      = $value;
    529         $data['type']       = $field['flickr_content_type'];
    530         $data['thumb_size'] = $field['flickr_thumb_size'];
    531         $data['large_size'] = $field['flickr_large_size'];
    532         $data['user_id']    = $field['flickr_user_id'];
    533         $data['api_key']    = $field['flickr_api_key'];
     533        $data['items']             = $value;
     534        $data['type']              = $field['flickr_content_type'];
     535        $data['flickr_show_limit'] = $field['flickr_show_limit'];
     536        $data['thumb_size']        = $field['flickr_thumb_size'];
     537        $data['large_size']        = $field['flickr_large_size'];
     538        $data['user_id']           = $field['flickr_user_id'];
     539        $data['api_key']           = $field['flickr_api_key'];
    534540
    535541        return $data;
     
    584590    function format_value( $value, $post_id, $field ) {
    585591        // bail early if no value
    586         if( empty($value)) {
     592        if(empty($value)) {
    587593            return $value;
    588594        }
     
    603609
    604610            if ($value['type'] == 'sets' || $value['type'] == 'galleries') {
     611                // Set default to get if flickr_show_limit does not exist
     612                if(!isset($value['flickr_show_limit'])) {
     613                    $value['flickr_show_limit'] = '500';
     614                }
     615
    605616                // Get photos from Flickr based on set/gallery id
    606617                $sets = array();
    607618                foreach($value['items'] as $id) {
    608619                    if ($value['type'] == 'sets') {
    609                         $photos = $f->photosets_getPhotos($id, 'url_o');
     620                        $photos = $f->photosets_getPhotos($id, 'url_o', null, $value['flickr_show_limit']);
    610621                        $name = 'photoset';
    611622                    }
    612623                    elseif ($value['type'] == 'galleries') {
    613                         $photos = $f->galleries_getPhotos($id, 'url_o');
     624                        $photos = $f->galleries_getPhotos($id, 'url_o', $value['flickr_show_limit']);
    614625                        $name = 'photos';
    615626                    }
Note: See TracChangeset for help on using the changeset viewer.