I have just installed media + media_gallery beta3 in a standard drupal 7 install. I am using a Omega8's aegir standard hosting. The modules all installed without a hitch but when I click "Add media" nothing happens. I opened firbug console and there is a js error:

Drupal.media is undefined
media_gallery.addimage.js line 14

11 Drupal.media_gallery.open_browser = function (event) {
12 event.preventDefault();
13 var pluginOptions = { 'id': 'media_gallery', 'multiselect' : true , 'types': ['image', 'video']};
14 Drupal.media.popups.mediaBrowser(Drupal.media_gallery.add_media, pluginOptions);
15 };

I have cleared cache and the problem persists. Anyone have any ideas wha't causing this? Also, is there a way to bypass this? As of now I can't add media to the gallery.

Comments

michaelfillier’s picture

UPDATE: The popup is working properly when js aggregation is enabled...strange!

wendallsan’s picture

Hi all,

I'm getting a similar error using the same modules and version of Drupal.

I've enabled JS aggregation, but this has not resolved my problem.

When I try to add a new image to a gallery, either by uploading a new image or selecting one from the 'library', nothing appears to happen on the page. In firebug, I can see that my POST returned a 404 error:

The requested URL /media-gallery/add-images/7/jayMV87ufj1MESY-FskRNw3c7eiki1VYXVFw8Hr9Pyw was not found on this server.

Looking at my server with an FTP client, there is no 'media-gallery' folder, and the images available in the library are simply in my /sites/default/files folder. Selecting the "Add media" option when adding images to the gallery DOES successfully upload the image to the server (into the /sites/default/files directory), but the image is not added to the gallery, instead I get the 404 error listed above.

Any help?

markkelly1982’s picture

I have the same error as above.

JacobSingh’s picture

@michaelfillier
Can you please re-confirm on HEAD? I have aggregation off and it is working

@wendallsan, you may need to enable "clean urls".
http://drupal.org/getting-started/clean-urls

JacobSingh’s picture

Status: Needs review » Active

Please mark "Needs review" only when there is code attached.

wendallsan’s picture

Thanks, enabling 'clean url's' resolved my problem. The Media Gallery is working well now.

JacobSingh’s picture

Title: Drupal.media is undefined when clicking "Add media" on gallery page » Add images link doesn't work w/o clean URLs

Thanks! now we know what the bug is :)

michaelfillier’s picture

I trashed the sandbox site I was working on and started fresh, everything was working the second time around. Although I still cannot get the media gallery working properly, due to some sort of thumbnail issue. Since this is not critical at the moment I will be checking back once the modules are updated.

tsvenson’s picture

I just updated to latest dev version of the media galley and this works without patches, including the thumbnail generation after setting the display for it.

tsvenson’s picture

Status: Active » Reviewed & tested by the community

Forgot to change status.

sara78’s picture

Sorry, does media gallery works only woth clean url on? I've installed the latest version and have the problem descripted here. My clean url are off: should I take them on? (I have problems in taking them on, but this is another story...).

thank you!!

JacobSingh’s picture

Status: Reviewed & tested by the community » Fixed

Yes, it is broken w/o clean URLs in the beta-3 version. You should switch to the newest release.

Status: Fixed » Closed (fixed)

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

chri-st’s picture

any news on this issue - i still have the same error. Images are uploaded to sites/default/files - but I can't add the images to the gallery. Nothing happens - no image and no error.

I use: Media 7.x-1.0-beta4, Media Gallery 7.x-1.x-dev (2011-May-25)

After submitting I get something like this in Firebug console {"result":true,"items":[{"fid":"80","title":null,"data":""},{"fid":"79","title":null,"data":""}]}

at /admin/config/media/galleries I get Fatal error: Cannot access empty property in /var/www/zoinet/htdocs/modules/field/field.attach.inc on line 197

clean ulrs are enabled and working

Mehnaz’s picture

I am also getting the same issue, can anyone please help me out.

Fatal error: Cannot access empty property in \modules\field\field.attach.inc on line 197

m-patate’s picture

Version: 7.x-1.0-beta3 » 7.x-1.0-beta5

If the clean-url module is unabled, you can try to modify the media_gallery.addimage.js file :
Replace the line (28 in beta-5 version) where src variable is build by (just add the ?q= to the basePath) :
var src = Drupal.settings.basePath + '?q=media-gallery/add-images/' + Drupal.settings.mediaGalleryNid + '/' + Drupal.settings.mediaGalleryToken;
I know it's not the better & cleaner solution but it's working for me.

dirkjohnson’s picture

Version: 7.x-1.0-beta5 » 7.x-1.0-beta6
Component: Code » Documentation
Priority: Normal » Minor

Just in case someone else has the same issue I did, which took me all night and much of the day to discover, and which clean urls ultimately fixed after much fidgeting and fussing with permissions and Media Gallery configurations and comparisons with Drupal Gardens installation:

Drupal installed on shared Linux hosting at http://x.x.x.x/~dir/dir2 where "dir2" is Drupal 7.7 root.

The Clean URL test would appear to run but yield no result of any sort.

Everything else in Drupal worked (works) without issue, even though I've been using Drupal for all of a week. Figured it must have been the tilda. When I pointed one of the URLs I keep for testing directly at Drupal root, voila! Both Clean URL and Media Gallery came alive.

David_Rothstein’s picture

The clean URL problem was actually a duplicate of #1000702: Ajax Callbacks fail if Clean URLs are not enabled. That actually was never fixed (even in the most recent 7.x-1.0-beta6 version), but I did just commit a fix for it now. So it should no longer be a problem in the next release.

It sounds to me like the original issue posted here (as well as some of the subsequent comments) didn't have anything to do with clean URLs, though.... However, since this issue has been marked "closed" for a long time, please create new issues if you are still experiencing problems (one issue per problem; don't bunch unrelated problems together in the same issue). Thanks.