summaryrefslogtreecommitdiffstatshomepage
path: root/core/modules/media/src/Annotation/MediaSource.php
blob: cd9c2347fc19b5cc08f92c0bf0a89d9938fd300e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php

namespace Drupal\media\Annotation;

use Drupal\Component\Annotation\Plugin;

/**
 * Defines a media source plugin annotation object.
 *
 * Media sources are responsible for implementing all the logic for dealing
 * with a particular type of media. They provide various universal and
 * type-specific metadata about media of the type they handle.
 *
 * Plugin namespace: Plugin\media\Source
 *
 * For a working example, see \Drupal\media\Plugin\media\Source\File.
 *
 * @see \Drupal\media\MediaSourceInterface
 * @see \Drupal\media\MediaSourceBase
 * @see \Drupal\media\MediaSourceManager
 * @see hook_media_source_info_alter()
 * @see plugin_api
 *
 * @Annotation
 */
class MediaSource extends Plugin {

  /**
   * The plugin ID.
   *
   * @var string
   */
  public $id;

  /**
   * The human-readable name of the media source.
   *
   * @var \Drupal\Core\Annotation\Translation
   *
   * @ingroup plugin_translatable
   */
  public $label;

  /**
   * A brief description of the media source.
   *
   * @var \Drupal\Core\Annotation\Translation
   *
   * @ingroup plugin_translatable
   */
  public $description = '';

  /**
   * The field types that can be used as a source field for this media source.
   *
   * @var string[]
   */
  public $allowed_field_types = [];

  /**
   * The classes used to define media source-specific forms.
   *
   * An array of form class names, keyed by ID. The ID represents the operation
   * the form is used for.
   *
   * @var string[]
   */
  public $forms = [];

  /**
   * A filename for the default thumbnail.
   *
   * The thumbnails are placed in the directory defined by the config setting
   * 'media.settings.icon_base_uri'. When using custom icons, make sure the
   * module provides a hook_install() implementation to copy the custom icons
   * to this directory. The media_install() function provides a clear example
   * of how to do this.
   *
   * @var string
   *
   * @see media_install()
   */
  public $default_thumbnail_filename = 'generic.png';

  /**
   * The metadata attribute name to provide the thumbnail URI.
   *
   * @var string
   */
  public $thumbnail_uri_metadata_attribute = 'thumbnail_uri';

  /**
   * The metadata attribute name to provide the thumbnail width.
   *
   * @var string
   */
  public $thumbnail_width_metadata_attribute = 'thumbnail_width';

  /**
   * The metadata attribute name to provide the thumbnail height.
   *
   * @var string
   */
  public $thumbnail_height_metadata_attribute = 'thumbnail_height';

  /**
   * The metadata attribute name to provide the thumbnail alt.
   *
   * "Thumbnail" will be used if the attribute name is not provided.
   *
   * @var string|null
   */
  public $thumbnail_alt_metadata_attribute;

  /**
   * The metadata attribute name to provide the thumbnail title.
   *
   * The name of the media item will be used if the attribute name is not
   * provided.
   *
   * @var string|null
   */
  public $thumbnail_title_metadata_attribute;

  /**
   * The metadata attribute name to provide the default name.
   *
   * @var string
   */
  public $default_name_metadata_attribute = 'default_name';

}