In #1291428: Add a 'full' view mode and use it for file/%file pages, we added a Full view mode for file entities. In #1051090: Revamp file view modes: migrate media_small to teaser, media_large to full, media_preview to preview; deprecate link & original, we decided to deprecate some of the Media module view modes, but keep Preview and add Teaser. However, discussed this today in IRC, and there's nothing Media-specific about Preview and Teaser, so these should be defined by the File Entity module. This patch does so, and uses Preview on the file/FID/edit page. There's no in-code use-case for Teaser, but a common administrative use-case would be to add a file field to a content type, and use the rendered file formatter (with View mode = Teaser) when the content is displayed as a teaser.

#15 file-entity-teaser-preview-1296268-15.patch2.94 KBRobW
PASSED: [[SimpleTest]]: [MySQL] 106 pass(es). View
#13 file-entity-teaser-preview-1296268-13.patch2.34 KBRobW
PASSED: [[SimpleTest]]: [MySQL] 106 pass(es). View
#10 file_entity_teaser_preview-1296268-10.patch2.34 KBsteinmb
PASSED: [[SimpleTest]]: [MySQL] 106 pass(es). View
#3 file_entity_teaser_preview-1296268-3.patch2.36 KBjief
PASSED: [[SimpleTest]]: [MySQL] 17 pass(es). View
#2 file_entity_teaser_preview-1296268-2.patch2.74 KBpbuyle
PASSED: [[SimpleTest]]: [MySQL] 17 pass(es). View
file_entity_teaser_preview.patch2.29 KBeffulgentsia
PASSED: [[SimpleTest]]: [MySQL] 37 pass(es). View


Dave Reid’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev

File entity has switched to a 7.x-2.x branch and the 7.x-1.x branch is no longer used. Please make sure to update your Git clones.

pbuyle’s picture

2.74 KB
PASSED: [[SimpleTest]]: [MySQL] 17 pass(es). View

The original patch applied on the 7.x-2.x until recently. Here is a reroll for the 7.x-2.x branch.

jief’s picture

2.36 KB
PASSED: [[SimpleTest]]: [MySQL] 17 pass(es). View

Here a new reroll for the 7.x-2.x branch following the upgrade from January 13

Dave Reid’s picture

Issue tags: +sprint, +Media Initiative
nodecode’s picture

just wondering what needs to happen for this to be implemented? waiting on this to be implemented to resolve a related issue

RobW’s picture

Seems to be working fine for me. [Edit] Ok, this actually doesn't seem to be working for me. Sorry for polluting the issue queue updates, I need to give it a couple hours before I post here from now on.

The patch in #3 doesn't seem to be changing anything.

RobW’s picture

Further investigation:

When applied by itself, with Media 2.x-dev:
No change to the view modes on Manage File Display,
In a content type's Manage Field Display, the rendered file select box lists "Full, Teaser, Preview, List, Preview, Small, Large, Original, Tokens".

When applied with the latest #1051090: Revamp file view modes: migrate media_small to teaser, media_large to full, media_preview to preview; deprecate link & original patch:
The view modes on Manage File Display show "Default, Link, Original",
The rendered file select box lists "Full, Teaser, Preview, Link, Original, Tokens".

RobW’s picture

Ahh, this was my fault. In previous versions the view modes provided by Media were enabled by default. After applying these patches on a fresh install, you'll have to go to File Types -> Manage Display and check the view modes you want to set custom displays for in Manage Display and Manage File Display.

This is closer to the way core handles custom view modes in the fields ui, and I like that. My only suggestion would be if teaser is meant to be the equivalent of teaser in fields, it should be enabled by default.

steinmb’s picture

+1 to enable the teaser pr. default. btw, what is blocking these two patches from going in?

steinmb’s picture

2.34 KB
PASSED: [[SimpleTest]]: [MySQL] 106 pass(es). View

Trying to get this issue moving again. Patch no longer apply. Re-rolling, though untested.

mrfelton’s picture

Status: Needs review » Needs work

Seems that it's impossible to export the display settings for Image display in teaser mode through features. To reproduce:

  1. At /admin/structure/file-types/manage/image/display select to use custom display settings for the teaser view mode.
  2. At /admin/structure/file-types/manage/image/file-display/teaser enable the Image display, and configure as desired.
  3. Try to export these settings into a feature

You cant. It's possible for all other view modes, including ones created with Display Suite. But for some reason, when it comes to the teaser mode, you can only export settings for some but not all of the display styles. This is what I could get into my feature:

features[file_display][] = image__teaser__file_field_file_default
features[file_display][] = image__teaser__file_field_file_rendered
features[file_display][] = image__teaser__file_field_file_table
features[file_display][] = image__teaser__file_field_file_url_plain
features[file_display][] = image__teaser__file_field_from_field
features[file_display][] = image__teaser__file_field_media_large_icon

Contrast with exports from other view modes:

features[file_display][] = image__cw_media_thumbnail_fixed__file_field_file_default
features[file_display][] = image__cw_media_thumbnail_fixed__file_field_file_rendered
features[file_display][] = image__cw_media_thumbnail_fixed__file_field_file_table
features[file_display][] = image__cw_media_thumbnail_fixed__file_field_file_url_plain
features[file_display][] = image__cw_media_thumbnail_fixed__file_field_from_field
features[file_display][] = image__cw_media_thumbnail_fixed__file_field_media_large_icon
features[file_display][] = image__cw_media_thumbnail_fixed__file_image

The one that's missing is the __file_image settings - the settings for the Image display style. There should be a image__teaser__file_image display. This doesn't appear as an option in the features file_display export options. I tried adding the relevant code to the feature manually, but when you do a revert the settings just get wiped out. ie. What I added manually was simply ignored.

mrfelton’s picture

Status: Needs work » Needs review

Actually, I think the problem noted above is because media module is implementing hook_file_default_displays(). Setting this back to needs review. Issue created in media module #1702700: Implementation of hook_file_default_displays makes it impossible to export image display settings via features.

RobW’s picture

2.34 KB
PASSED: [[SimpleTest]]: [MySQL] 106 pass(es). View

Duplicate of #10 with teaser 'custom settings' => TRUE to follow the pattern of Drupal's default content types.

I've been using #10 for a while with the patches in #1051090: Revamp file view modes: migrate media_small to teaser, media_large to full, media_preview to preview; deprecate link & original, and they're working fine. When we decide if teaser has custom settings by default, IMO this is RTBC.

RobW’s picture

A couple minor details.

  • Media_preview contained a warning:

    Changing the Preview view mode could have unintended side effects such as breaking the Media browser or WYSIWYG integration. Only change these display settings if you know what you are doing.

    Should we include one in file entity? Maybe something more general:

  • The Preview view mode is used for administrative tasks including file previews and in-editor placeholders. Changing these settings can break parts of your site.

  • Core sets the human readable name of the full view mode to "Full content". Should we match that here?
  • In order for modules to use the preview view mode, "custom settings" has to be enabled, so it should be on by default.
RobW’s picture

2.94 KB
PASSED: [[SimpleTest]]: [MySQL] 106 pass(es). View

Set the Preview view mode to have custom settings by default and added a warning to its manage file display page. Tried to get a little more general with the warning:

Some modules rely on the Preview view mode to function correctly. Changing these settings may break parts of your site.

Nodes have a closer connection to content, so "teaser" and "full content" make sense there. I think "full" is fine here.

Devin Carlson’s picture

Status: Needs review » Reviewed & tested by the community

The patch in #15 applied cleanly and successfully added the Preview and Teaser view modes.

Tested by:

  • Performing a fresh install of Drupal and File Entity
  • Visiting the file types page
  • Configuring the display and file display for the default, teaser and preview view modes
  • Displaying files with the view modes using various methods (views, Media's WYSIWYG integration, etc)
  • Verifying that the files displayed correctly
madar’s picture

I applied #15 and #1051090: Revamp file view modes: migrate media_small to teaser, media_large to full, media_preview to preview; deprecate link & original.

File preview on edit form working as expected after setting up 'Manage File Display' of image file type.
Also works on media_gallery multiedit page with multiform module.

ParisLiakos’s picture

Status: Reviewed & tested by the community » Fixed
+++ b/file_entity.file_api.incundefined
@@ -308,16 +308,22 @@ function file_view_file($file, $displays = 'full', $langcode = NULL) {
+  if (! isset($element)) {

removed space before isset and commited


ParisLiakos’s picture

hmm, sorry for giving all commit credit @RobW, :/
steinmb, mongolito404, jief and effulgentsia whose original work this is i owe you one!
and i definitely need some sleep after commiting #1051090: Revamp file view modes: migrate media_small to teaser, media_large to full, media_preview to preview; deprecate link & original

i hope you are good with some irc karma:P

<rootatwc> effulgentsia++++
<rootatwc> mongolito404++
<rootatwc> jief++
RobW’s picture

Yeah, I just tied up the loose ends. Thanks and credit to everyone else for writing the meat of it.

steinmb’s picture

Great work everyone! :) Both this and the revamped view-mode patch got in, and at the same day. YAY!

Automatically closed -- issue fixed for 2 weeks with no activity.