Projet

Général

Profil

Révision 9e88ab34

Ajouté par Assos Assos il y a plus de 6 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/file_entity/file_entity.file.inc
150 150
 * Implements hook_file_mimetype_mapping_alter().
151 151
 */
152 152
function file_entity_file_mimetype_mapping_alter(&$mapping) {
153
  // Add support for mka and mkv.
154
  // @todo Remove when http://drupal.org/node/1443070 is fixed in core.
155
  $new_mappings['mka'] = 'audio/x-matroska';
156
  $new_mappings['mkv'] = 'video/x-matroska';
153
  // For info on adding new mime-types to core: http://drupal.org/node/1443070.
157 154

  
158
  // Add support for weba, webm, and webp.
159
  // @todo Remove when http://drupal.org/node/1443070 is fixed in core.
160
  $new_mappings['weba'] = 'audio/webm';
161
  $new_mappings['webm'] = 'video/webm';
162
  $new_mappings['webp'] = 'image/webp';
155
  // @todo. Remove after fixing this in core http://drupal.org/node/2912875.
156
  // Add support for autocad drawings.
157
  $new_mappings['dwg'] = 'application/acad';
158
  // For info on adding new mime-types to file_entity: drupal.org/node/2900830.
163 159

  
164 160
  foreach ($new_mappings as $extension => $mime_type) {
165 161
    if (!in_array($mime_type, $mapping['mimetypes'])) {
......
178 174
 */
179 175
function file_entity_file_load($files) {
180 176
  // Add alt and title text to images.
177
  file_entity_set_title_alt_properties($files);
178

  
179
  // Load and unserialize metadata.
180
  $results = db_query("SELECT * FROM {file_metadata} WHERE fid IN (:fids)", array(':fids' => array_keys($files)));
181

  
182
  foreach ($results as $result) {
183
    $name = $result->name;
184

  
185
    // image.module required height and width to be properties of the file.
186
    if ($name == 'height' || $name == 'width') {
187
      $files[$result->fid]->$name = unserialize($result->value);
188
    }
189

  
190
    $files[$result->fid]->metadata[$name] = unserialize($result->value);
191
  }
192
}
193

  
194
/**
195
 * Implements hook_entitycache_ENTITY_TYPE_load().
196
 */
197
function file_entitycache_file_load($files) {
198
  // Integrates with entitycache - ensures the alt and title text on images is
199
  // localized.
200
  file_entity_set_title_alt_properties($files);
201
}
202

  
203
/**
204
 * Set the title / alt properties of file objects.
205
 *
206
 * @param array $files List of file entities.
207
 */
208
function file_entity_set_title_alt_properties($files) {
181 209
  $alt = variable_get('file_entity_alt', '[file:field_file_image_alt_text]');
182 210
  $title = variable_get('file_entity_title', '[file:field_file_image_title_text]');
183 211

  
184 212
  $replace_options = array(
185 213
    'clear' => TRUE,
186 214
    'sanitize' => FALSE,
215
    'language' => $GLOBALS['language'],
187 216
  );
188 217

  
189 218
  foreach ($files as $file) {
......
207 236
      $file->title = decode_entities($output);
208 237
    }
209 238
  }
210

  
211
  // Load and unserialize metadata.
212
  $results = db_query("SELECT * FROM {file_metadata} WHERE fid IN (:fids)", array(':fids' => array_keys($files)));
213

  
214
  foreach ($results as $result) {
215
    $name = $result->name;
216

  
217
    // image.module required height and width to be properties of the file.
218
    if ($name == 'height' || $name == 'width') {
219
      $files[$result->fid]->$name = unserialize($result->value);
220
    }
221

  
222
    $files[$result->fid]->metadata[$name] = unserialize($result->value);
223
  }
224 239
}
225 240

  
226 241
/**

Formats disponibles : Unified diff