Revision 2b3c8cc1
Added by Assos Assos about 9 years ago
drupal7/sites/all/modules/file_entity/file_entity.file.inc | ||
---|---|---|
166 | 166 |
* Implements hook_file_load(). |
167 | 167 |
*/ |
168 | 168 |
function file_entity_file_load($files) { |
169 |
// Add alt and title text to images. |
|
169 | 170 |
$alt = variable_get('file_entity_alt', '[file:field_file_image_alt_text]'); |
170 | 171 |
$title = variable_get('file_entity_title', '[file:field_file_image_title_text]'); |
171 | 172 |
|
... | ... | |
179 | 180 |
|
180 | 181 |
// Load alt and title text from fields. |
181 | 182 |
if (!empty($alt)) { |
182 |
$file->alt = token_replace($alt, array('file' => $file), $replace_options); |
|
183 |
$output = token_replace($alt, array('file' => $file), $replace_options); |
|
184 |
|
|
185 |
// @todo Remove once https://www.drupal.org/node/1713164 is fixed. |
|
186 |
// There is currently no way to get the raw alt text returned from the |
|
187 |
// token so we revert the encoding done during tokenization. |
|
188 |
$file->alt = decode_entities($output); |
|
183 | 189 |
} |
184 | 190 |
if (!empty($title)) { |
185 |
$file->title = token_replace($title, array('file' => $file), $replace_options); |
|
191 |
$output = token_replace($title, array('file' => $file), $replace_options); |
|
192 |
|
|
193 |
// @todo Remove once https://www.drupal.org/node/1713164 is fixed. |
|
194 |
// There is currently no way to get the raw title text returned from the |
|
195 |
// token so we revert the encoding done during tokenization. |
|
196 |
$file->title = decode_entities($output); |
|
186 | 197 |
} |
187 | 198 |
} |
188 | 199 |
|
189 | 200 |
// Load and unserialize metadata. |
190 | 201 |
$results = db_query("SELECT * FROM {file_metadata} WHERE fid IN (:fids)", array(':fids' => array_keys($files))); |
202 |
|
|
191 | 203 |
foreach ($results as $result) { |
192 |
$files[$result->fid]->metadata[$result->name] = unserialize($result->value); |
|
204 |
$name = $result->name; |
|
205 |
|
|
206 |
// image.module required height and width to be properties of the file. |
|
207 |
if ($name == 'height' || $name == 'width') { |
|
208 |
$files[$result->fid]->$name = unserialize($result->value); |
|
209 |
} |
|
210 |
|
|
211 |
$files[$result->fid]->metadata[$name] = unserialize($result->value); |
|
193 | 212 |
} |
194 | 213 |
} |
195 | 214 |
|
Also available in: Unified diff
Weekly update of contrib modules