diff --git a/manualcrop.module b/manualcrop.module
index 73d624e..f5c4219 100644
--- a/manualcrop.module
+++ b/manualcrop.module
@@ -380,8 +380,10 @@ function manualcrop_media_element_after_build($element) {
 
   // Update the cached options.
   $element_js_class = drupal_html_class('js-media-element-' . $element['#id']);
-  $cid = $element['browse_button']['#attached']['js'][0]['data']['media']['elements']['.' . $element_js_class]['global']['options'];
-  cache_set('media_options:' . $cid, $element['#media_options']['global'], 'cache_form', REQUEST_TIME + 21600);
+  if(!empty($element['browse_button']['#attached']['js'][0]['data']['media']['elements']['.' . $element_js_class]['global']['options'])) {
+    $cid = $element['browse_button']['#attached']['js'][0]['data']['media']['elements']['.' . $element_js_class]['global']['options'];
+    cache_set('media_options:' . $cid, $element['#media_options']['global'], 'cache_form', REQUEST_TIME + 21600);
+  }
 
   // Attach the options as javascript settings.
   if (!empty($element['#attached']['js'])) {
