protected function MediaDealerBase::getImageFieldData in Media Migration 8
Get the names of the image type fields from the source database.
Parameters
\Drupal\Core\Database\Connection $connection: The database connection of the source Drupal 7 instance.
bool $field_names_only: Whether only the name of the image fields should be returned. Defaults to TRUE.
Return value
array The array of the available image fields.
2 calls to MediaDealerBase::getImageFieldData()
- Image::getSettingsFromImageFields in src/
Plugin/ media_migration/ file_entity/ Image.php - Discovers enabled properties based on the image field configurations.
- MediaDealerBase::getImageData in src/
MediaDealerBase.php - Returns alt, title, with and height properties of the specified file.
File
- src/
MediaDealerBase.php, line 370
Class
- MediaDealerBase
- Base implementation of media dealer plugins.
Namespace
Drupal\media_migrationCode
protected function getImageFieldData(Connection $connection, $field_names_only = TRUE) : array {
$image_field_query = $connection
->select('field_config', 'fs')
->fields('fs', [
'field_name',
])
->condition('fs.type', 'image')
->condition('fs.active', 1)
->condition('fs.deleted', 0)
->condition('fs.storage_active', 1)
->condition('fi.deleted', 0);
$image_field_query
->join('field_config_instance', 'fi', 'fs.id = fi.field_id');
if ($field_names_only) {
return array_keys($image_field_query
->execute()
->fetchAllAssoc('field_name'));
}
$image_field_query
->addField('fs', 'data', 'field_storage_data');
$image_field_query
->addField('fi', 'data', 'field_instance_data');
$image_fields_data = [];
foreach ($image_field_query
->execute()
->fetchAll(\PDO::FETCH_ASSOC) as $item) {
foreach ([
'field_storage_data',
'field_instance_data',
] as $data_key) {
$item[$data_key] = unserialize($item[$data_key]);
}
$image_fields_data[] = $item;
}
return $image_fields_data;
}