When adding media through the WYSIWYG browser, if a user doesn't have administer media permission, then after selecting the media to insert, they get a blank dialog.

I'm on my laptop, so can't create a patch atm. I'll try to remember to do so tomorrow. Meanwhile, here's the fix:

line 174 of media.module:

  $items['media/%media/format-form'] = array(
    'title' => 'Style selector',
    'description' => 'Choose a format for a piece of media',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('media_format_form', 1),
    'access arguments' => array('administer media'),
    'weight' => 0,
    'file' => 'includes/media.filter.inc',
    'theme callback' => 'media_dialog_get_theme_name',
  );

becomes

  $items['media/%media/format-form'] = array(
    'title' => 'Style selector',
    'description' => 'Choose a format for a piece of media',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('media_format_form', 1),
    'access callback' => 'media_access',
    'access arguments' => array('view'),
    'weight' => 0,
    'file' => 'includes/media.filter.inc',
    'theme callback' => 'media_dialog_get_theme_name',
  );

It would need an update to catch the new menu item permission as well.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

aaron’s picture

Version: 7.x-1.0-beta4 » 7.x-1.x-dev
Status: Active » Needs review
FileSize
881 bytes

and here's the patch.

aaron’s picture

oops. with the update function...

effulgentsia’s picture

Status: Needs review » Fixed

Updated update function number to chase recent 7.x-1.x commits, and committed to 7.x-1.x. Thanks.

Status: Fixed » Closed (fixed)

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

rickvug’s picture

Don't mind me, just uploading a version of the patch with just the menu change for use in a make file.

David_Rothstein’s picture

Status: Closed (fixed) » Needs review
FileSize
451 bytes

The menu rebuild added in this issue isn't necessary because update.php rebuilds the menu anyway. So the attached followup patch changes the update function to a no-op instead.

Thanks to @effulgentsia for making that suggestion, vs. my plan of renumbering the update functions entirely which would have hurt anyone running off a dev version (not that you should be doing that with production sites anyway) :)

David_Rothstein’s picture

Hm, so it turns out that if you are using Drush 4 (or Drush 5), running updates doesn't actually clear caches/rebuild the menu, due to this bug: #602182: updatedb should clear cache

If you're doing updates via Drush 3 (or visiting update.php via the UI), it does, though.

David_Rothstein’s picture

Status: Needs review » Closed (fixed)

Given that the menu_rebuild() might be needed for people using Drush 4, I guess my followup patch shouldn't be committed. I'm therefore setting this issue back to "fixed".

We're probably going to run the patch temporarily in Drupal Gardens, though (since we control the environment so don't need to worry about the Drush issue, and we'd like to avoid thousands of menu rebuilds if we can)... so it's there above if anyone else needs it for a similar kind of situation :)

thoughtcat’s picture

Issue summary: View changes
Status: Closed (fixed) » Active

I can't see why this issue was closed as fixed - it's four years old, but I'm using the most up to date version of the module and it's still only possible for users who have the "administer media" permission to upload images. If that isn't the case, what am I doing wrong? I do want my authenticated users to be able to upload an image to my site, but I don't see why they should be allowed to delete any existing images or manage the file types and theme settings in admin/config/media/browser

robbertnl’s picture

Status: Active » Fixed

Add permission `Media WYSIWYG: Use Media WYSIWYG in an editor` for your roles.

thoughtcat’s picture

Hi Robert, where is that permission please? On the site to which this ticket applies I have Media 7.x-1.4 installed which doesn't have a "Media WYSIWYG" sub-module option and thus no associated permission. But even on another site I manage where I have Media 7.x-2.0-alpha4 installed, which does have Media WYSIWYG installed and activated, there's still no such permission "Media WYSIWYG: Use Media WYSIWYG in an editor" that I can see.

thoughtcat’s picture

Status: Fixed » Needs review
robbertnl’s picture

Sorry, i am using 7.x-2.x-dev (2015-Oct-01). Its defined in the function media_wysiwyg_permission

  • effulgentsia committed ee7ff80 on 7.x-3.x
    #1143950 by aaron: Fixed Users unable to add media through WYSIWYG...
joseph.olstad’s picture

Fixed "May 16, 2011 22:14" thanks to @David.Rothstein and @aaron

joseph.olstad’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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