-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add function to get all media for a node #2
Comments
The Manage Media view bundled with the Islandora module provides a REST API to get all media attached to a node using requests like // $json is the JSON returned by the above URL.
$array = json_decode($json, true);
$media_fields = array(
'field_media_file',
'field_media_image',
'field_media_audio_file',
'field_media_video_file',
);
$media_use_tags = array();
foreach ($array as $media) {
foreach ($media_fields as $media_field) {
if (array_key_exists($media_field, $media)) {
if (!in_array($media['field_media_use'][0]['url'], $media_use_tags)) {
$tag_url = $media['field_media_use'][0]['url'];
}
$media_use_tags[$tag_url][] = $media[$media_field][0]['url'];
}
}
}
print_r($media_use_tags); This will parse out URLs to the media files and group them by media use (Preservation Master, Original File, etc.); Array
(
[/taxonomy/term/15] => Array
(
[0] => http://localhost:8000/_flysystem/fedora/2018-11/iCamp%20CA%20-%20mjordan%20-%20taxi%20receipt.png
)
[/taxonomy/term/19] => Array
(
[0] => http://localhost:8000/_flysystem/fedora/2018-11/iCamp%20CA%20-%20mjordan%20-%20hotel%20receipt.pdf
[1] => http://localhost:8000/_flysystem/fedora/2018-11/VP_academic_conference_fund_2019_islandora_conference.pdf
)
[/taxonomy/term/16] => Array
(
[0] => http://localhost:8000/_flysystem/fedora/2018-11/sample.mp3
[1] => http://localhost:8000/_flysystem/fedora/2018-11/sample.mp4
)
) These Drupal URLs will need to be converted to Fedora URLs (via Gemini) if Riprap is polling Fedora. |
To get the taxonomy term name, use: $term = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->load($tid);
$name = $term->getName(); |
Closed with 683cab0. |
This will be used to generate the media-level report described in #1.
The text was updated successfully, but these errors were encountered: