Problem/Motivation

The 'media' field type is now deprecated in favour of the 'file' field type.

Proposed resolution

While the media field type is deprecated, it's still supported in Media 1.x and legacy support is provided in File entity 2.x. Many Drupal 7 sites will have these fields. So we shouldn't be eliminating support for them yet. Rather, we should simply add support for the 'file' field type and update the field created at install from the deprecated media to the file type.

Focusing on 1.x fixes will help pave the way for 2.x support.

Remaining tasks

Remove 2.x specific changes from this patch. They can be addressed as followup in #1244204: Make media_gallery work with media-7.x-2.x branch. See the issues identified in #16.

User interface changes

API changes

Original report by helmo

I came across #974958: More settings for Multimedia asset field, where Dave Reid mentions in #1 that the 'Multimedia asset' filed is deprecated. Note sure what his means for the media_gallery module...

Does anyone have more details about this field?

Comments

To followup on myself...

Enabling the 'mediafield' module which is included in the media-7.x-2.x branch would be a temporary solution.

In the long run we should convert to the 'file' field as the media module has done

You mention it already in an other issue. Here are two issues, that may give a hint.
#1324316: Explain why Media Field module is deprecated in .info
#1349058: Convert 'Media' fields to 'File' fields that use the 'Media file selector' widget

If i read it correct, the media field is replaced by the file field. The media field is moved to a submodule (see #1201936: Move the media field to a non-required submodule)
But i think this is only for media 2.x ? Not the 1.x branch.

Switching to the File Field seems great and all, but none of the solutions for displaying embedded videos like YouTube in a node now work in Drupal 7.

See: http://drupal.org/node/1414606
And see: http://drupal.org/node/1077088

The only way it seems to be able to display YouTube videos in a node, from a field is to use multimedia asset field, and the media file selector widget, as provided by Media module.

There is also http://drupal.org/project/video_embed_field, but those fields don't seem to be visible to the Rules engine.

So, video is dead for Drupal 7?!

OK, I have tried with a file field with the control set to "Media file selector" but when I see the node I get a file list with the name linked to the file, how do I make it show the media instead ? like when I used the media field and could choose how to display it.

Dying to know the answer to this one.

until we don't have another solution we will have to use a Multimedia asset (deprecated) field with Media file selector as widget. Is the only Way I've found to see my YouTube or Vimeo videos embebed in my Web page.

Ok I know this is deprecated, but what does is matter? It is working and when a drupal update come (drupal 8 i.e.) I guess a media update will come too, and this field will be another field already updated, won't be?

Greetings

Media v1.1 solves the issue with video by including the correct formatter for the core File field.
#1390878: File fields do not have the media formatter option.

You can now have both images and video in the same field, using core File field and Media file selector. Just select "Rendered File" as output format under "Manage Display".

Status:Active» Fixed

As this seems to be resolved according to #7, I am closing the issue.

Status:Fixed» Active

Sorry, I was unclear. Media 1.1 has solved the underlying problem, but Media Gallery still has to change it's default Node type to use the core File Field instead of the deprecated Media Asset field.

Title:Multimedia asset field deprecated?Use file field instead of deprecated media asset field

There might be some pointers in this issue #1244204: Make media_gallery work with media-7.x-2.x branch on how to make it work. However, and hook_update_xxxx() probably also needs to be written. @esbite Do you want to create a patch?

Issue tags:+Beta9-blocker

Tagging.

Category:support» task

Status:Active» Needs review
StatusFileSize
new3.88 KB

here is all that was in http://drupal.org/node/1244204#comment-5877124 except the changes to update functions in effect removing the specific version dependency and changing

media_gallery_field_formatter_info() and function _media_gallery_controlled_fields()

this patch also includes changes from http://drupal.org/node/1677150#comment-6213384 cause they seemed reasonable.

what it doesn`t include is an update path http://drupal.org/node/1349058

Component:Miscellaneous» Code
StatusFileSize
new5.5 KB

here is the same patch including some changes from http://drupal.org/node/1244204#comment-6196610

Title:Use file field instead of deprecated media asset fieldSupport file field as well as deprecated media asset field
Status:Needs review» Needs work

While the media field type is deprecated, it's still supported in Media 1.x and legacy support is provided in File entity 2.x. Many Drupal 7 sites will have these fields. So we shouldn't be eliminating support for them yet. Rather, this patch should simply add support for the 'file' field type and update the field created at install from the deprecated media to the file type.

Focusing on 1.x fixes will help pave the way for 2.x support.

+++ b/media_gallery.fields.inc
@@ -13,7 +13,7 @@ function media_gallery_field_formatter_info() {
-      'field types' => array('media'),
+      'field types' => array('file'),

'media' should not be removed here.

+++ b/media_gallery.fields.inc
@@ -88,7 +88,10 @@ function media_gallery_field_formatter_view($entity_type, $entity, $field, $inst
+    foreach ($items as $delta => &$item) {

Indentation error.

+++ b/media_gallery.fields.inc
@@ -88,7 +88,10 @@ function media_gallery_field_formatter_view($entity_type, $entity, $field, $inst
+    if (empty($item['file'])) {
+      $item['file'] = file_load($item['fid']);
+    }

Why might the 'file' key be empty? A comment here would be good.

+++ b/media_gallery.fields.inc
@@ -107,6 +110,7 @@ function media_gallery_field_formatter_view($entity_type, $entity, $field, $inst
+  unset($item);

Why is this required?

+++ b/media_gallery.info
@@ -5,7 +5,7 @@ package = Media
-dependencies[] = media (<1.99)
+dependencies[] = media

This patch should be limited to adding support within Media 1.x. 2.x compatibility can be addressed as follow-up in #1244204: Make media_gallery work with media-7.x-2.x branch.

+++ b/media_gallery.install
@@ -183,7 +183,7 @@ function _media_gallery_controlled_fields() {
-      'type' => 'media',
+      'type' => 'file',

'media' should not be removed here.

+++ b/media_gallery.module
@@ -849,10 +849,10 @@ function media_gallery_form($node, $form_state) {
-  if (strpos($form_id, 'media_edit') === 0) {
+  if (strpos($form_id, 'file_entity_edit') === 0) {
     // Act on both the regular and multiform versions of the edit form.
-    if ($form_id === 'media_edit' || preg_match('/^media_edit_[0-9]+$/', $form_id)) {
-      // Prepopulate the media_edit form with our best guess at the image title.
+   if ($form_id === 'file_entity_edit' || preg_match('/^file_entity_edit_[0-9]+$/', $form_id)) {

Are these changes for 2.x compatibility? Will the file_entity_edit form work with 'media' type fields?

+++ b/media_gallery.module
@@ -975,7 +975,7 @@ function media_gallery_form_media_gallery_node_form_alter(&$form, &$form_state)
+function media_gallery_form_file_entity_edit_alter(&$form, &$form_state) {

Ditto.

+++ b/media_gallery.pages.inc
@@ -282,8 +282,8 @@ function media_gallery_add_images($node) {
-      $file['title'] = null;
-      $file['data'] = '';
+      $file['display'] = 1;
+      $file['description'] = '';

I don't follow these changes. If the added keys are for file fields, likely we need to keep the title and data lines.

+++ b/media_gallery.pages.inc
@@ -391,7 +391,7 @@ function media_gallery_media_page_multiedit($node) {
-  $form = media_page_multiedit($files);
+  $form = media_file_page_edit_multiple($files);

Are these for media 2.x?

@nedjo. Maybe you could have a stab on creating a patch that introduces the file field, but retains the media field. If not, the current plan is to remove support for the media asset field and write an update function which converts those fields to file field. We are going to introduce 2.x-branch support in the next beta version.

Presumably removing 'media' type field support would have to be done in the media or file_entity module since those modules own the involved fields.

Even if there were an update here in media_gallery to convert legacy fields, as long as those fields are still supported in media and file_entity, users of those modules could turn on media_gallery and hit problems. (Yes, media_gallery could test on install as well as update, and run a field conversion, but that seems to be well outside the scope of what should happen on enabling/testing a new module.) So, as far as I can tell, unless 'media' type field support is dropped entirely in D7, the only realistic option is to continue supporting it.

I've tried to specify some of the remaining work in #16.

Worth noting that field_update_field() throws an exception if trying to change the type of an existing field. An update to change existing fields from 'media' to 'file' couldn't use the field API.

@nedjo I think I agree that we could just add the file field also. Do you have time to try to create a patch which makes this happen?

Status:Needs work» Needs review
StatusFileSize
new7.07 KB

Here is a new patch which should support both the media field and the file field. Also, this patch will create a file field instead of a media field if media 2.x is used instead of media 1.x.

I believe that this patch answers "Make media gallery work for both 1.x and 2.x branches of media for clean installs using file instead of media and mediafield. ".

A few notes concerning nedjo's comments in #16:

+++ b/media_gallery.fields.inc
@@ -107,6 +110,7 @@ function media_gallery_field_formatter_view($entity_type, $entity, $field, $inst
+  unset($item);

Why is this required ? I don't know exactly, but I left it in the patch I'm providing.

+++ b/media_gallery.info
@@ -5,7 +5,7 @@ package = Media
-dependencies[] = media (<1.99)
+dependencies[] = media

I left this part because making media_gallery work with both media and file makes it work with media 7.x-2.x branch, so these 2 issues are actually the same.

+++ b/media_gallery.pages.inc
@@ -282,8 +282,8 @@ function media_gallery_add_images($node) {
-      $file['title'] = null;
-      $file['data'] = '';
+      $file['display'] = 1;
+      $file['description'] = '';

Again I left those in my patch. If someone can provide explanation on these, I would also be interested.

The rest of the comments should be fixed in this new patch.

StatusFileSize
new7.78 KB

New patch which fixes small bugs in #21

Thanks for the patch. There is some whitespace issues.

git apply media_gallery-1391332-22.patch
media_gallery-1391332-22.patch:152: trailing whitespace.
warning: 1 line adds whitespace errors.

Could you add some notes on how you tested it yourself, to speed up the review process?

StatusFileSize
new7.55 KB

That one should fix the whitespace issue.

StatusFileSize
new34.03 KB

Great work already, but some issues with the current dev.

When i patch the module and do a (clean) install, create a gallery and click on 'Add media' i see 1 popups launched. (see attachement).

When i save a picture, the form reloads and adds another popup. (only ones, but not the ctools version, the other page wide one, also see attachement, below the one on top.)

(Sometimes) when i click (on first create / add picture) i'm redirected to the front page.

Most of the times the node isn't reloaded, new pictures are not visible, you first have to close the extra popup you get and reload the page to see them.

And i can't select multiple pictures at ones, have to submit them one by one.

But it does work! Pictures are added to the gallery and i don't have the media field submodule enabled.
(working on a testsite with media 2.x, d7.15, views, styles, etc, etc.)
(will debug some more after i get some sleep, i found this patch and i just had to test it.)

Status:Needs review» Needs work

This patch adds some comments and fixes issues with patch in #24.
It does not contain any changes to info and install file.

Tested with:
media 1.x
media 1.x (by changing db-schema from media to file)
media 2.x (by changing db-schema from media to file and info file)

Status:Needs work» Needs review
StatusFileSize
new8.31 KB

I applied #28 with info and install changes against beta8 and media 2.x.

-dependencies[] = media (<1.99)
+dependencies[] = media
-      'type' => 'media',
+      'type' => 'file',

After enable module create gallery, add, edit and remove images working great.

Can more people please test the upgrade path from using Media 1.x --> 2.x and upgrading media gallery accordingly with this patch. We need to have a couple of more people confirm, that it works correctly on their sites before moving to RTBC.

What should be the upgrade path steps?

1. Install/enable media 1.x and media_gallery -beta8 (or -dev?).
2. Create gallery, add images.
3. Upgrade media to 2.x (enable media field?).
4. Apply media_gallery patch (combine #25 and #28 ?).
5. Check gallery and images, add new images. Create new gallery add images.

I tested upgrade path and steps changed a bit.

1. I installed media 1.x and media_gallery beta8.
2. I created gallery1 and added pictures.
3. (changed) I applied patch #27 on media_gallery and replaced .info and .install files from an other media_gallery tree I patched with #24.
4. (changed) I created gallery2. Then I uploaded and rearranged pictures in both gallery1 and gallery2. Everything looked good, and worked as expected.
5. (changed) Media upgrade path says disable Media dependent modules so I disabled media gallery. I replaced media module with file_field and media 2.x-unstable6. Then ran update.php which enable "Media field".
6. (new) I enabled media_gallery and checked old galleries. Added gallery3. Uploaded pictures to all three galleries and rearranged them. This worked good.

In some cases there was a problem when I added pictures to different version galleries from media browser library. What I mean: when I added a newly uploaded picture to media gallery1 it was duplicated in some cases or when I added an old (which was uploaded to gallery1) picture to gallery2 or gallery3 it was duplicated too in some cases.

So this duplication need testing but upgrade process seems working.

re-rolled patch so it applies to the latest dev.

Marked #1677150: Media gallery tries to use deprecated media_edit form as duplicate.

So this duplication need testing but upgrade process seems working.

I can reproduce this with media 2.x-unstable6, but not with media 2.x-dev. So this seem to be fixed.

I can confirm, it is a media 2.x-unstable6 problem. Duplication happens when I choose image from Media Browser 'My files' or 'View Library'. After upgrade to media 2.x-dev there is no duplication.

Status:Needs review» Reviewed & tested by the community

I also maually tested the update-process.

1. I installed media 1.x and media_gallery-dev
2. I created gallery1 and added pictures.
3. (changed) I applied patch #34 on media_galler-dev
4. Updated media 1.x tot media 2.x and file entity 2.x (both dev versions). Then ran update.php which enable "Media field".

Checked galleries, and those seemed all good. No errors nor warnings.
Setting to RTBC

Status:Reviewed & tested by the community» Fixed

@Moloc - do you mean patch 33 (not 34)? By patch 34 are you referring to the comment number on this page?
There is a patch mentioned in patch 33 so I am guessing you mean that:
http://drupal.org/node/1391332#comment-6581690

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

Issue summary:View changes

Add summary.