Пример #1
0
 function render_field_settings($field)
 {
     /*
      *  acf_render_field_setting
      *
      *  This function will create a setting for your field. Simply pass the $field parameter and an array of field settings.
      *  The array of settings does not require a `value` or `prefix`; These settings are found from the $field array.
      *
      *  More than one setting can be added by copy/paste the above code.
      *  Please note that you must also have a matching $defaults value for the field name (font_size)
      */
     // Render return value radio
     acf_render_field_setting($field, array('label' => __('Return Value', 'acf-focal_point'), 'instructions' => __('Specify the returned value on front end', 'acf-focal_point'), 'type' => 'radio', 'name' => 'save_format', 'layout' => 'horizontal', 'choices' => array('object' => __("Image Object", 'acf'), 'tag' => __("Image Tag", 'acf'))));
     // Render return size select
     acf_render_field_setting($field, array('label' => __('Image Size', 'acf-focal_point'), 'instructions' => __('Size of image when returning an image tag', 'acf-focal_point'), 'type' => 'select', 'name' => 'image_size', 'choices' => acf_get_image_sizes()));
     // Render preview size select
     acf_render_field_setting($field, array('label' => __('Preview Size', 'acf-focal_point'), 'instructions' => __('Image used to create a Focal Point. Should be around the same image ratio as Image Size', 'acf-focal_point'), 'type' => 'select', 'name' => 'preview_size', 'choices' => acf_get_image_sizes()));
 }
Пример #2
0
 function render_field_settings($field)
 {
     // return_format
     acf_render_field_setting($field, array('label' => __('Return Value', 'acf'), 'instructions' => __('Specify the returned value on front end', 'acf'), 'type' => 'radio', 'name' => 'return_format', 'layout' => 'horizontal', 'choices' => array('array' => __("Image Array", 'acf'), 'url' => __("Image URL", 'acf'), 'id' => __("Image ID", 'acf'))));
     // preview_size
     acf_render_field_setting($field, array('label' => __('Preview Size', 'acf'), 'instructions' => __('Shown when entering data', 'acf'), 'type' => 'select', 'name' => 'preview_size', 'choices' => acf_get_image_sizes()));
     // library
     acf_render_field_setting($field, array('label' => __('Library', 'acf'), 'instructions' => __('Limit the media library choice', 'acf'), 'type' => 'radio', 'name' => 'library', 'layout' => 'horizontal', 'choices' => array('all' => __('All', 'acf'), 'uploadedTo' => __('Uploaded to post', 'acf'))));
 }
Пример #3
0
 function render_field_settings($field)
 {
     // clear numeric settings
     $clear = array('min', 'max', 'min_width', 'min_height', 'min_size', 'max_width', 'max_height', 'max_size');
     foreach ($clear as $k) {
         if (empty($field[$k])) {
             $field[$k] = '';
         }
     }
     // min
     acf_render_field_setting($field, array('label' => __('Minimum Selection', 'acf'), 'instructions' => '', 'type' => 'number', 'name' => 'min'));
     // max
     acf_render_field_setting($field, array('label' => __('Maximum Selection', 'acf'), 'instructions' => '', 'type' => 'number', 'name' => 'max'));
     // preview_size
     acf_render_field_setting($field, array('label' => __('Preview Size', 'acf'), 'instructions' => __('Shown when entering data', 'acf'), 'type' => 'select', 'name' => 'preview_size', 'choices' => acf_get_image_sizes()));
     // library
     acf_render_field_setting($field, array('label' => __('Library', 'acf'), 'instructions' => __('Limit the media library choice', 'acf'), 'type' => 'radio', 'name' => 'library', 'layout' => 'horizontal', 'choices' => array('all' => __('All', 'acf'), 'uploadedTo' => __('Uploaded to post', 'acf'))));
     // min
     acf_render_field_setting($field, array('label' => __('Minimum', 'acf'), 'instructions' => __('Restrict which images can be uploaded', 'acf'), 'type' => 'text', 'name' => 'min_width', 'prepend' => __('Width', 'acf'), 'append' => 'px'));
     acf_render_field_setting($field, array('label' => '', 'type' => 'text', 'name' => 'min_height', 'prepend' => __('Height', 'acf'), 'append' => 'px', 'wrapper' => array('data-append' => 'min_width')));
     acf_render_field_setting($field, array('label' => '', 'type' => 'text', 'name' => 'min_size', 'prepend' => __('File size', 'acf'), 'append' => 'MB', 'wrapper' => array('data-append' => 'min_width')));
     // max
     acf_render_field_setting($field, array('label' => __('Maximum', 'acf'), 'instructions' => __('Restrict which images can be uploaded', 'acf'), 'type' => 'text', 'name' => 'max_width', 'prepend' => __('Width', 'acf'), 'append' => 'px'));
     acf_render_field_setting($field, array('label' => '', 'type' => 'text', 'name' => 'max_height', 'prepend' => __('Height', 'acf'), 'append' => 'px', 'wrapper' => array('data-append' => 'max_width')));
     acf_render_field_setting($field, array('label' => '', 'type' => 'text', 'name' => 'max_size', 'prepend' => __('File size', 'acf'), 'append' => 'MB', 'wrapper' => array('data-append' => 'max_width')));
     // allowed type
     acf_render_field_setting($field, array('label' => __('Allowed file types', 'acf'), 'instructions' => __('Comma separated list. Leave blank for all types', 'acf'), 'type' => 'text', 'name' => 'mime_types'));
 }
Пример #4
0
 function render_field_settings($field)
 {
     /*
      *  acf_render_field_setting
      *
      *  This function will create a setting for your field. Simply pass the $field parameter and an array of field settings.
      *  The array of settings does not require a `value` or `prefix`; These settings are found from the $field array.
      *
      *  More than one setting can be added by copy/paste the above code.
      *  Please note that you must also have a matching $defaults value for the field name (font_size)
      */
     // crop_type
     acf_render_field_setting($field, array('label' => __('Crop type', 'acf-image_crop'), 'instructions' => __('Select the type of crop the user should perform', 'acf-image_crop'), 'type' => 'select', 'name' => 'crop_type', 'layout' => 'horizontal', 'class' => 'crop-type-select', 'choices' => array('hard' => __('Hard crop', 'acf-image_crop'), 'min' => __('Minimal dimensions', 'acf-image_crop'))));
     // target_size
     $sizes = acf_get_image_sizes();
     // added
     $instructions = __('Select the target size for this field', 'acf-image_crop');
     if ($this->getOption('retina_mode')) {
         $instructions .= '<br><br><em><strong>' . __('Retina mode is enabled - user will be required to select an image twice this size', 'acf-image_crop') . '</strong></em>';
     }
     // added END
     $sizes['custom'] = __('Custom size', 'acf-image_crop');
     acf_render_field_setting($field, array('label' => __('Target size', 'acf-image_crop'), 'instructions' => $instructions, 'type' => 'select', 'name' => 'target_size', 'class' => 'target-size-select', 'choices' => $sizes));
     // width - conditional: target_size == 'custom'
     acf_render_field_setting($field, array('label' => __('Custom target width', 'acf-image_crop'), 'instructions' => __('Leave blank for no restriction (does not work with hard crop option)', 'acf-image_crop'), 'type' => 'number', 'name' => 'width', 'class' => 'custom-target-width custom-target-dimension', 'append' => 'px'));
     // height - conditional: target_size == 'custom'
     acf_render_field_setting($field, array('label' => __('Custom target height', 'acf-image_crop'), 'instructions' => __('Leave blank for no restriction (does not work with hard crop option)', 'acf-image_crop'), 'type' => 'number', 'name' => 'height', 'class' => 'custom-target-height custom-target-dimension', 'append' => 'px'));
     // preview_size
     acf_render_field_setting($field, array('label' => __('Preview Size', 'acf'), 'instructions' => __('Shown when entering data', 'acf'), 'type' => 'select', 'name' => 'preview_size', 'choices' => acf_get_image_sizes()));
     // force_crop
     acf_render_field_setting($field, array('label' => __('Force crop', 'acf-image_crop'), 'instructions' => __('Force the user to crop the image as soon at it is selected', 'acf-image_crop'), 'type' => 'radio', 'layout' => 'horizontal', 'name' => 'force_crop', 'choices' => array('yes' => __('Yes', 'acf'), 'no' => __('No', 'acf'))));
     // save_in_media_library
     acf_render_field_setting($field, array('label' => __('Save cropped image to media library', 'acf-image_crop'), 'instructions' => __('If the cropped image is not saved in the media library, "Image URL" is the only available return value.', 'acf-image_crop'), 'type' => 'radio', 'layout' => 'horizontal', 'name' => 'save_in_media_library', 'class' => 'save-in-media-library-select', 'choices' => array('yes' => __('Yes', 'acf'), 'no' => __('No', 'acf'))));
     // only show this setting if the global option for retina mode is not activated
     // retina mode
     if (!$this->getOption('retina_mode')) {
         acf_render_field_setting($field, array('label' => __('Retina/@2x mode ', 'acf-image_crop'), 'instructions' => __('Require and crop double the size set for this image. Enable this if you are using plugins like WP Retina 2x.', 'acf-image_crop'), 'type' => 'radio', 'layout' => 'horizontal', 'name' => 'retina_mode', 'choices' => array('yes' => __('Yes', 'acf'), 'no' => __('No', 'acf'))));
     }
     // return_format
     acf_render_field_setting($field, array('label' => __('Return Value', 'acf'), 'instructions' => __('Specify the returned value on front end', 'acf'), 'type' => 'radio', 'name' => 'save_format', 'layout' => 'horizontal', 'class' => 'return-value-select', 'choices' => array('object' => __("Image Array", 'acf'), 'url' => __("Image URL", 'acf'), 'id' => __("Image ID", 'acf'))));
     // library
     acf_render_field_setting($field, array('label' => __('Library', 'acf'), 'instructions' => __('Limit the media library choice', 'acf'), 'type' => 'radio', 'name' => 'library', 'layout' => 'horizontal', 'choices' => array('all' => __('All', 'acf'), 'uploadedTo' => __('Uploaded to post', 'acf'))));
 }
Пример #5
0
 function render_field_settings($field)
 {
     // min / max
     $field['min'] = empty($field['min']) ? '' : $field['min'];
     $field['max'] = empty($field['max']) ? '' : $field['max'];
     // min
     acf_render_field_setting($field, array('label' => __('Minimum Selection', 'acf'), 'instructions' => '', 'type' => 'number', 'name' => 'min', 'placeholder' => '0'));
     // max
     acf_render_field_setting($field, array('label' => __('Maximum Selection', 'acf'), 'instructions' => '', 'type' => 'number', 'name' => 'max', 'placeholder' => '0'));
     // preview_size
     acf_render_field_setting($field, array('label' => __('Preview Size', 'acf'), 'instructions' => __('Shown when entering data', 'acf'), 'type' => 'select', 'name' => 'preview_size', 'choices' => acf_get_image_sizes()));
     // library
     acf_render_field_setting($field, array('label' => __('Library', 'acf'), 'instructions' => __('Limit the media library choice', 'acf'), 'type' => 'radio', 'name' => 'library', 'layout' => 'horizontal', 'choices' => array('all' => __('All', 'acf'), 'uploadedTo' => __('Uploaded to post', 'acf'))));
 }
 function render_field_settings($field)
 {
     /*
      *  acf_render_field_setting
      *
      *  This function will create a setting for your field. Simply pass the $field parameter and an array of field settings.
      *  The array of settings does not require a `value` or `prefix`; These settings are found from the $field array.
      *
      *  More than one setting can be added by copy/paste the above code.
      *  Please note that you must also have a matching $defaults value for the field name (font_size)
      */
     // crop_type
     acf_render_field_setting($field, array('label' => __('Crop type', 'acf-image_crop'), 'instructions' => __('Select the type of crop the user should perform', 'acf-image_crop'), 'type' => 'select', 'name' => 'crop_type', 'layout' => 'horizontal', 'class' => 'crop-type-select', 'choices' => array('hard' => __('Hard crop', 'acf-image_crop'), 'min' => __('Minimal dimensions', 'acf-image_crop'))));
     // target_size
     $sizes = acf_get_image_sizes();
     $sizes['custom'] = __('Custom size', 'acf-image_crop');
     acf_render_field_setting($field, array('label' => __('Target size', 'acf-image_crop'), 'instructions' => __('Select the target size for this field', 'acf-image_crop'), 'type' => 'select', 'name' => 'target_size', 'class' => 'target-size-select', 'choices' => $sizes));
     // width - conditional: target_size == 'custom'
     acf_render_field_setting($field, array('label' => __('Custom target width', 'acf-image_crop'), 'instructions' => __('Leave blank for no restriction (does not work with hard crop option)', 'acf-image_crop'), 'type' => 'number', 'name' => 'width', 'class' => 'custom-target-width custom-target-dimension'));
     // height - conditional: target_size == 'custom'
     acf_render_field_setting($field, array('label' => __('Custom target height', 'acf-image_crop'), 'instructions' => __('Leave blank for no restriction (does not work with hard crop option)', 'acf-image_crop'), 'type' => 'number', 'name' => 'height', 'class' => 'custom-target-height custom-target-dimension'));
     // preview_size
     acf_render_field_setting($field, array('label' => __('Preview size', 'acf-image_crop'), 'instructions' => __('Select the preview size for this field', 'acf-image_crop'), 'type' => 'select', 'name' => 'preview_size', 'choices' => acf_get_image_sizes()));
     // force_crop
     acf_render_field_setting($field, array('label' => __('Force crop', 'acf-image_crop'), 'instructions' => __('Force the user to crop the image as soon at it is selected', 'acf-image_crop'), 'type' => 'radio', 'layout' => 'horizontal', 'name' => 'force_crop', 'choices' => array('yes' => 'Yes', 'no' => 'No')));
     // save_in_media_library
     acf_render_field_setting($field, array('label' => __('Save cropped image to media library', 'acf-image_crop'), 'instructions' => __('If the cropped image is not saved in the media library, "Image URL" is the only available return value.', 'acf-image_crop'), 'type' => 'radio', 'layout' => 'horizontal', 'name' => 'save_in_media_library', 'class' => 'save-in-media-library-select', 'choices' => array('yes' => 'Yes', 'no' => 'No')));
     // return_format
     acf_render_field_setting($field, array('label' => __('Return Value', 'acf-image_crop'), 'instructions' => __('Specify the returned value on front end', 'acf-image_crop'), 'type' => 'radio', 'name' => 'save_format', 'layout' => 'horizontal', 'class' => 'return-value-select', 'choices' => array('url' => __("Image URL", 'acf'), 'id' => __("Image ID", 'acf'), 'object' => __("Image Object", 'acf'))));
     // library
     acf_render_field_setting($field, array('label' => __('Library', 'acf'), 'instructions' => __('Limit the media library choice', 'acf'), 'type' => 'radio', 'name' => 'library', 'layout' => 'horizontal', 'choices' => array('all' => __('All', 'acf'), 'uploadedTo' => __('Uploaded to post', 'acf'))));
 }