With file_entity + media, file entities are often displayed in different contexts. We need to be able to apply core image styles to images that are file entities; the default view modes are insufficient. For example, if you have a "square_thumbnail" image style, which file entity view mode does it correspond with?

Basically, there should be a file_entity view mode for each core image style. Adding image styles as file view modes means that, for as many image styles as a site has, you can always format a media image with it.

The attached patch does exactly that. File entity view modes based on core image styles are disabled by default, and can be enabled via checkboxes in the "custom display settings" collapsible fieldset on the "manage display" tab for file entities.

I'm going to re-test this patch. It would be extremely handy to have a way to add view modes on file entities, and this patch coordinates file entity view modes with image styles and displays image files using the matching image style automatically.

* Things fail horribly if you for some reason don't have image module enabled. I have added a check for that.
* In order for the image to be rendered automatically when new image styles are added, we need to set the status to enabled in file_displays_alter.

I disagree with the File entity module creating a view mode for each image style. Instead, I think the goal of making it easier for admins to use their image styles on file fields can be achieved via an "Image style override" setting on the "Rendered file" formatter. Will try to post a patch showing this in the next couple days.

A site can easily have 20 or so image styles, and having that many secondary tabs in "manage display" and "manage file display" gets unwieldy.

You don't want to necessarily configure different ways of displaying the fields attached to the file, for each image style, but that's what you need to do when you add a view mode.

I think the underlying desire in this issue is to make it easier for the administrator to choose an image style when configuring the display of a file field, without needing to go through a bunch of hassle of adding and configuring a new view mode to do so. So, here's a patch that implements #8/#9.

For use-cases where creating new view modes is needed, modules like Display Suite let you do that.

Conceptually I really like what this patch aims to do. It doesn't yet work properly in a variety of situations. Here are some examples.

1) Configuring the display on the Manage Fields tab for a content type. The admin UI works very well, but overriding the image style does not change the output of the image when the node is rendered.

2) Configuring the display of an individual image uploaded to a node by using the Formatter Field module. See attached screenshot. Again, the admin UI works, but there is no change to the image when displayed. Also, there is a PHP warning on the node/edit form.

Actually, it does work both from Manage Fields, and in conjunction with the Formatter Field. The issue was I had the view mode set to 'Original' and then tried to override the style on that. That doesn't work because of your check for !empty($element[$delta]['file']['#style_name']). The Original view mode doesn't have an assigned Image Style. So as is this patch will only let you override the display for view modes that have an assigned image style. In some ways it makes sense, but in other ways it is confusing. Just because the site builder configured the field to display the Original, does that mean the user shouldn't be able to override the output?

Also, I think we might want to consider providing the ability to limit the available image styles on a per field basis. Not all image styles make sense in all situations, and you wouldn't want to provide content editors with options that make no sense or give them the ability to break page. This is probably really only an issue when using Formatter Field.

The patch is really great and such but when is it pushed to the official release of file_entity?

It's been almost a year since this patch was offered and more than a year since this issue was created.

P.S.
If and When this patch is pushed I think mrfelton problem should also be handled (comment #14) by either overwriting the image style even if none is used in the file display or by adding another option to the image style select list in the file display form ('decided in the field formatter').

I think I'm running into this issue while attempting to render image file entities in a View. I'm attempting to create a View that renders the image file of an image file entity. I'm only allowed to choose View Modes and not Styles.

I applied this patch but it didn't seem to help with the View. Should this patch work in this situation?

@caschbre: If "Styles" == Styles module, its use is deprecated. If "Styles" == image styles, currently you'll want to configure your image styles per view mode, and then use the view modes in views. If you need a new view mode for your view, check out the Entity View Modes module.

I can see a use for this override functionality, but I'm not sure it needs to be in File Entity module. It's basically a shortcut around the best practice of configuring all formatters per view mode, aka per context. If someone were to port Effulgentsia's patch to a new module, ++. For file entity, my vote is works as designed/ won't fix, unless this addresses something besides overriding image styles for image formatters in view modes.

I'm of similar opinion as effulgentsia in #10. Creating view modes simply to render an image using a different image style doesn't quite seem right. I may have 20 image styles to render the same image in different use cases but creating 20 view modes to handle each image style seems excessive.

I could see situations where I'd want to render the same view mode in different scenarios where all I change is the image style used.

In the case of a file field that can accept multiple file types, wouldn't you then want to display each file type at that image style size, and isn't that a good reason to create a new view mode? Not attacking, just wondering.

That's a good point Rob. I think in that scenario a view mode might be the best way. In my current situation, I'm simply dealing with image file types so I hadn't really considered other file types. I can see the case for both options... which allows the choice / control up to the site builder.

Right now I'm utilizing the entity view module to create a new view mode that applies 'only' to the image file type. Then in that view mode I can choose the image style I want. I'm having to do this for each image style I want to use.

I'm rendering image files in a View. Ideally, I'd love to be able to simply render the image file and choose which image style to use for that particular view display. What I'm having to do is create and configure the view mode, then choose that view mode in the view display.

When using the File Entity Link module, the patch of #10 stops working within a regular node and in Views. Not sure if it the bug (if you can call it that) resides in the patch above or the mentionned module.

I'd like to add my opinion that forcing all images into a pre-defined set of view modes (that apply to ANY file entity type) seems crazy to me. Even worse is those view modes store settings like if the media item is linked or not! If you continued down this path, you could have view modes for things like:

And many of these only apply to a specific type of media like video. While I like the direction that the view modes is going, I think the approach needs to be re-evaluated.

FWIW, I think the approach I'm going to attempt to take is create some standard view modes for images and attempt to use image resize filter for the rest. Unfortunately that integration is broken as well right now.