Same name and namespace in other branches
  1. 8.x-1.x exif.drush.inc \__drush_exif_media_update() 1 comment

The drush media update.

Parameters

string $type: The type.

Return value

int Returns $count.

1 call to __drush_exif_media_update()
drush_exif_update in ./exif.drush.inc
Implements Drush callback.

File

./exif.drush.inc, line 352

Code

function __drush_exif_media_update($type = '') {
    $query = "SELECT m.mid FROM {media} m WHERE m.bundle = :type";
    $result = \Drupal::database()->query($query, [
        ':type' => $type,
    ]);
    $count = 0;
    foreach ($result as $record) {
        // Load the media object from the database.
        $media = Media::load($record->mid);
        // Resave the media to make exif changes.
        $media->save();
        $count++;
    }
    \Drupal::logger(dt('Updated %count %type medias.', [
        '%count' => $count,
        '%type' => $type,
    ]));
    return $count;
}