Revision 2b3c8cc1
Added by Assos Assos about 9 years ago
drupal7/sites/all/modules/media/includes/media.fields.inc | ||
---|---|---|
15 | 15 |
'label' => t('Media browser'), |
16 | 16 |
'field types' => array('file', 'image'), |
17 | 17 |
'settings' => array( |
18 |
'allowed_types' => array('image'), |
|
18 |
'allowed_types' => array( |
|
19 |
'image' => 'image', |
|
20 |
), |
|
19 | 21 |
'browser_plugins' => array(), |
20 |
'allowed_schemes' => array('public', 'private'), |
|
22 |
'allowed_schemes' => array( |
|
23 |
'public' => 'public', |
|
24 |
), |
|
21 | 25 |
), |
22 | 26 |
'behaviors' => array( |
23 | 27 |
'multiple values' => FIELD_BEHAVIOR_CUSTOM, |
... | ... | |
77 | 81 |
* Implements hook_field_widget_form(). |
78 | 82 |
*/ |
79 | 83 |
function media_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) { |
80 |
|
|
81 |
// Add display_field setting to field because media_field_widget_form() assumes it is set. |
|
82 |
if (!isset($field['settings']['display_field'])) { |
|
83 |
$field['settings']['display_field'] = 0; |
|
84 |
} |
|
85 |
|
|
86 | 84 |
$defaults = array( |
87 | 85 |
'fid' => 0, |
88 | 86 |
'display' => !empty($field['settings']['display_default']), |
... | ... | |
164 | 162 |
$elements['#description'] = $element['#description']; |
165 | 163 |
$elements['#field_name'] = $element['#field_name']; |
166 | 164 |
$elements['#language'] = $element['#language']; |
167 |
$elements['#display_field'] = $field['settings']['display_field'];
|
|
165 |
$elements['#display_field'] = intval(!empty($field['settings']['display_field']));
|
|
168 | 166 |
|
169 | 167 |
// Add some properties that will eventually be added to the media upload |
170 | 168 |
// field. These are added here so that they may be referenced easily through |
... | ... | |
185 | 183 |
// If the display field is present make sure its unchecked value is saved. |
186 | 184 |
$field = field_widget_field($element, $form_state); |
187 | 185 |
if (empty($input['display'])) { |
188 |
$input['display'] = $field['settings']['display_field'] ? 0 : 1;
|
|
186 |
$input['display'] = intval(!empty($field['settings']['display_field']));
|
|
189 | 187 |
} |
190 | 188 |
} |
191 | 189 |
|
... | ... | |
450 | 448 |
// "operations" column. |
451 | 449 |
$operations_elements = array(); |
452 | 450 |
foreach (element_children($widget) as $sub_key) { |
453 |
if (isset($widget[$sub_key]['#type']) && $widget[$sub_key]['#type'] == 'submit') {
|
|
451 |
if (isset($widget[$sub_key]['#type']) && ($widget[$sub_key]['#type'] == 'submit' || $widget[$sub_key]['#type'] == 'link')) {
|
|
454 | 452 |
hide($widget[$sub_key]); |
455 | 453 |
$operations_elements[] = &$widget[$sub_key]; |
456 | 454 |
} |
... | ... | |
543 | 541 |
'media_large_icon' => array( |
544 | 542 |
'label' => t('Large filetype icon'), |
545 | 543 |
'field types' => array('file'), |
544 |
'settings' => array( |
|
545 |
'image_style' => '', |
|
546 |
), |
|
546 | 547 |
), |
547 | 548 |
); |
549 |
|
|
548 | 550 |
return $formatters; |
549 | 551 |
} |
550 | 552 |
|
553 |
/** |
|
554 |
* Implements hook_field_formatter_settings_form(). |
|
555 |
* |
|
556 |
* Legacy support for the "Large filetype icon" file field formatter. |
|
557 |
* @see media_field_formatter_info() |
|
558 |
*/ |
|
559 |
function media_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) { |
|
560 |
$display = $instance['display'][$view_mode]; |
|
561 |
$settings = $display['settings']; |
|
562 |
|
|
563 |
$image_styles = image_style_options(FALSE, PASS_THROUGH); |
|
564 |
$element['image_style'] = array( |
|
565 |
'#title' => t('Image style'), |
|
566 |
'#type' => 'select', |
|
567 |
'#default_value' => $settings['image_style'], |
|
568 |
'#empty_option' => t('None (original image)'), |
|
569 |
'#options' => $image_styles, |
|
570 |
); |
|
571 |
|
|
572 |
return $element; |
|
573 |
} |
|
574 |
|
|
575 |
/** |
|
576 |
* Implements hook_field_formatter_settings_summary(). |
|
577 |
* |
|
578 |
* Legacy support for the "Large filetype icon" file field formatter. |
|
579 |
* @see media_field_formatter_info() |
|
580 |
*/ |
|
581 |
function media_field_formatter_settings_summary($field, $instance, $view_mode) { |
|
582 |
$display = $instance['display'][$view_mode]; |
|
583 |
$settings = $display['settings']; |
|
584 |
|
|
585 |
$summary = array(); |
|
586 |
|
|
587 |
$image_styles = image_style_options(FALSE, PASS_THROUGH); |
|
588 |
// Unset possible 'No defined styles' option. |
|
589 |
unset($image_styles['']); |
|
590 |
// Styles could be lost because of enabled/disabled modules that defines |
|
591 |
// their styles in code. |
|
592 |
if (isset($image_styles[$settings['image_style']])) { |
|
593 |
$summary[] = t('Image style: @style', array('@style' => $image_styles[$settings['image_style']])); |
|
594 |
} |
|
595 |
else { |
|
596 |
$summary[] = t('Original image'); |
|
597 |
} |
|
598 |
|
|
599 |
return implode('<br />', $summary); |
|
600 |
} |
|
601 |
|
|
551 | 602 |
/** |
552 | 603 |
* Implements hook_field_formatter_view(). |
553 | 604 |
* |
... | ... | |
558 | 609 |
$element = array(); |
559 | 610 |
|
560 | 611 |
if ($display['type'] == 'media_large_icon') { |
561 |
// Use the media_thumbnail image style so that the output in media browser |
|
562 |
// is consistent. |
|
563 | 612 |
foreach ($items as $delta => $item) { |
564 | 613 |
$element[$delta] = array( |
565 | 614 |
'#theme' => 'media_formatter_large_icon', |
566 | 615 |
'#file' => (object) $item, |
616 |
'#style_name' => $display['settings']['image_style'], |
|
567 | 617 |
); |
568 | 618 |
} |
569 | 619 |
} |
Also available in: Unified diff
Weekly update of contrib modules