In build 7.x-2.0-beta1+10-dev, the media browser's Browse button doesn't appear when using Entity Embed to embed a file into the editor. But it disables the file-upload field, thus preventing the use of Entity Embed at all.

The problem appears to be the changes to media.js introduced in beta1+10; using media.js from beta1+9 fixes the issue. Given that this is the principal change in beta1+10, it means this latest build is incompatible with Entity Embed.

I can't actually figure out why the updated javascript doesn't attach properly, hopefully someone who understands it better than me will be able to!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Rick J created an issue. See original summary.

ron_s’s picture

Status: Active » Needs review
FileSize
1.99 KB

There are a few issues with the changes made in the most recent version:

  1. The selectors cannot be concatenated as they are for each item. They need to be separate statements.
  2. .once and .removeOnce should be applied as part of a function, rather than in a string of selectors.
  3. The use of .siblings is not appropriate. It needs to be either .find or .children. Since .find is slightly more performant than .children, .find has been used in the patch.

See the attached file for review.

ron_s’s picture

After further testing, patch #2 needs some adjustment. It works correctly for the Entity Embed button, but does not render the form item correctly when it is a basic file field on a content type. The code that had been added was correct.

This patch combines the two together.

jose.cely’s picture

I solved the problem with patch #2 .
I have Drupal 7.44 and patch Media 7.x-2.0-beta2 and works.

Thanks a lot!

ron_s’s picture

@jose.cely, you should not use Patch #2. It does not work correctly for fields on a content type that have been set to use the Media Browser.

You must use Patch #3.

smsivaprakaash’s picture

I tried applying both the patches, it is not working as expected(Media browser button is not getting displayed)
Media module- 7.x-2.0-beta2
Entity Embed - 7.x-2.0-alpha3+3-dev
File entity - 7.x-2.0-beta3+3-dev

ron_s’s picture

@smsivaprakaash, please see the title of this thread. The patch is for 7.x-2.x-dev, not 7.x-2.0-beta2. In fact, patches should never be applied to release versions of code. They are always to the -dev version.

smsivaprakaash’s picture

yeah right, but i saw the following tread says, it worked for beta2 version. So i thought it would be appropriate to post here. I ll give a try with the dev version.
Thanks!

ron_s’s picture

He also said he used patch #2, when I specifically said to use patch #3. Patch #2 is bad.

Schubie’s picture

Is there a solution for the missing media browser button? I can only see the button in beta1. Any version above beta1 seems to be broken to me.

codemann’s picture

Same issue here after updating media from beta1 to the latest rc on an existing website. We're not using entity_embed, yet still no media browser button.
Yet on a clean install from a new project this upgrade never caused issues.

Maybe a different issue, but it feels close?!

RickJ’s picture

A few people have noted that this can be fixed by changing the calling code that adds the media-browser form item to specify the #theme property as 'media-widget'. See https://www.drupal.org/node/2288487.

However, this breaks backward compatibility with the media module's own API, so seems to me a bit unsatisfactory. It would be better to correct the default #theme property in the media module itself. The attached one-line patch does this, and works in my testing.

I don't know if this change has any negative side-effects, maybe someone can check it out?

joseph.olstad’s picture

Thanks @Rick J , your fix appears to be the correct one.

  • Rick J authored 693b0cf on 7.x-2.x
    Issue #2690669 by ron_s, Rick J: Media browser not displayed with Entity...
joseph.olstad’s picture

Status: Needs review » Fixed

committed to 7.x-2.x dev

Status: Fixed » Closed (fixed)

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