diff --git a/contrib/file_styles/file_styles.module b/contrib/file_styles/file_styles.module index 177cf87..778423d 100644 --- a/contrib/file_styles/file_styles.module +++ b/contrib/file_styles/file_styles.module @@ -29,10 +29,6 @@ function file_styles_styles_register() { * This will determine the correct style container corresponding to media type. */ function file_styles_styles_filter($object, $element = NULL) { - // Media objects have the file stored as a property of the object. - if (isset($object->file)) { - $object = $object->file; - } // Ensure we're working against the fully loaded file object. $file = file_styles_uri_to_object($object->uri, TRUE); diff --git a/contrib/file_styles/includes/styles/FileStyles.inc b/contrib/file_styles/includes/styles/FileStyles.inc index 47735e9..5440743 100644 --- a/contrib/file_styles/includes/styles/FileStyles.inc +++ b/contrib/file_styles/includes/styles/FileStyles.inc @@ -42,10 +42,6 @@ class FileStyles extends StylesDefault { return $this->set('fid', $value); } function setObject($value) { - // Media objects have the file stored as a property of the object. - if (isset($value->file)) { - $value = $value->file; - } return $this->set('object', $value); } function getUri() { @@ -60,19 +56,6 @@ class FileStyles extends StylesDefault { } } function setUri($value) { - // Media objects don't store the URI on the 'item' part of the object, - // but rather nested within the ->file section. Unfortunately, nodes have - // their own URI scheme, that needs to be dealt with. - // @see http://drupal.org/node/797502. - if (is_array($value)) { - $object = $this->getObject(); - if (isset($object->uri)) { - $value = $object->uri; - } - else { - $value = NULL; - } - } return $this->set('uri', $value); } function getTitle() { diff --git a/styles.module b/styles.module index 2415026..6ef84c8 100644 --- a/styles.module +++ b/styles.module @@ -40,19 +40,13 @@ function styles_field_formatter_info() { function styles_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) { $element = array('#formatter' => $display['type']); foreach ($items as $delta => $item) { - // @todo This should be refactored, but for legacy reasons, we pass a - // context object containing both the field item keys and the entity - // properties, because there are current use-cases of each one being - // needed. For example, file_styles_styles_formatter_filter() expects - // $object to contain a file field's $item data, and - // theme_media_youtube_embed() expects $object to contain the entity's - // 'override' property. This came about because an early use-case of the - // Styles module is the Media module, where there is tight coupling - // between the entity and the field item. Creating a merged context object - // is an initial step towards making the Styles module usable by modules - // other than Media. See http://drupal.org/node/797502. - $object = (object) ((array) $item + (array) $entity); - $element[$delta] = array('#markup' => theme('styles_field_formatter', array('element' => $element, 'object' => $object))); + // @todo The variable name 'object' is misleading, but retained for + // backwards compatibility until a broader refactoring of the Styles + // module. For now, it's the $item array cast to an object. For File and + // Image fields, this is a fully loaded file object, because + // file_field_load() loads the referenced file and merges its properties + // into $item, but for other field types, it may simply be raw field data. + $element[$delta] = array('#markup' => theme('styles_field_formatter', array('element' => $element, 'object' => (object) $item, 'delta' => $delta, 'entity' => $entity))); } return $element; }