summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDevin Carlson2015-05-28 07:05:54 (GMT)
committerDevin Carlson2015-05-28 07:05:54 (GMT)
commit31142c281066bd9fa838161ad09ed4bafede0f6a (patch)
tree68d6a3c81deb6793bdb3c08ab983fe60c5ca4283
parentfe1c723482c53a1410ef988e21cb32c0146f79cf (diff)
Added a file operation for refreshing information from the source.
-rw-r--r--media_flickr.file.inc42
1 files changed, 42 insertions, 0 deletions
diff --git a/media_flickr.file.inc b/media_flickr.file.inc
new file mode 100644
index 0000000..94b6950
--- /dev/null
+++ b/media_flickr.file.inc
@@ -0,0 +1,42 @@
+<?php
+
+/**
+ * @file
+ * File hooks implemented by the Media: Flickr module.
+ */
+
+/**
+ * Implements hook_file_operations().
+ */
+function media_flickr_file_operations() {
+ $operations = array(
+ 'media_flickr_refresh' => array(
+ 'label' => t('Refresh Flickr information from source'),
+ 'callback' => 'media_flickr_cache_clear',
+ ),
+ );
+
+ return $operations;
+}
+
+/**
+ * Clear the cached Flickr content for the selected files.
+ */
+function media_flickr_cache_clear($fids) {
+ $fids = array_keys($fids);
+
+ $query = new EntityFieldQuery();
+ $results = $query
+ ->entityCondition('entity_type', 'file')
+ ->propertyCondition('uri', 'flickr:', 'STARTS_WITH')
+ ->propertyCondition('fid', $fids)
+ ->execute();
+
+ $files = file_load_multiple(array_keys($results['file']));
+
+ foreach ($files as $file) {
+ $wrapper = file_stream_wrapper_get_instance_by_uri($file->uri);
+ $local_path = $wrapper->getLocalThumbnailPath();
+ file_unmanaged_delete($local_path);
+ }
+}