Everything else works perfectly but this functionality of the module doesnt work for me. Please help me. Do i have to add something in the code or check something... dunno...!? cms is D7. 10x in advance.

Comments

moloc’s picture

There are theme issues with media_gallery.
Theme issue: #1085486: Reorder collection - Drag and drop re-ordering patch fix nothing with omega subtheme
Sorting issue: #1228094: Gallery rearranging is not stored

Are you able to fix your issue with this two issues? The problem are the css-selectors in the javascript file (see patch in the mentioned theme issue).

m4r71n’s picture

Yes, i gues so. I use fremework 3.x as base theme. I saw there is a fix (at http://drupal.org/node/1085486 #27 ) for this theme but not sure how to apply it to my theme. Can u give an advice? 10x again.

moloc’s picture

Title: Drag and drop image doesnt work in a custom made theme. » Drag and drop image doesnt work with the Framework theme

The patch mentioned in #1 does not fix the problem with your theme.

Here is the solution for theme Framework. Tested with version 7.x-3.6.

File: media_gallery.dragdrop.js
replace line 18:
var $gallery = $('body.page-node #block-system-main .node-media-gallery .media-gallery-media > .field-items').once('media-gallery-sortable');
with
var $gallery = $('body.page-node.node-type-media-gallery #main .content .media-gallery-media > .field-items').once('media-gallery-sortable');

and replace line 80:
var $toReorder = $('#block-system-main [id^=' + data.idPrefix + ']').addClass('media-gallery-to-reorder');
with
var $toReorder = $('#main [id^=' + data.idPrefix + ']').addClass('media-gallery-to-reorder');

Now drag & drop should work.

moloc’s picture

For those, who like patches, here it is. (For others, see comment #3).

Note: This patch works only with the Framework theme.

m4r71n’s picture

many 10xs! Works like charm...

lsolesen’s picture

@Moloc we should probably try to work out a method which works cross themes. Any ideas?

attheshow’s picture

Awesome. I was able to do the same two changes mentioned in #3 by Moloc for my own theme (using different classes and IDs that were specific to my theme) and it got the drag and drop working perfectly. Thanks!

I do agree that not forcing themers to correct this JS file would be ideal though.

moloc’s picture

Title: Drag and drop image doesnt work with the Framework theme » Drag and drop does not work - solution for all themes
Category: support » bug
Status: Active » Needs review
StatusFileSize
new2.47 KB

So lets see, what do problem is:

Some HTML5 themes use article instead of node. Therefore we cannot use body.page-node and .node-media-gallery.
Other themes use #main instead of #block-system-main, so we can't use that too.

Next, i tried to add some code to media_gallery_preprocess_node():

  if($variables['node']->type == 'media_gallery' && $variables['view_mode'] == 'full') {
    $variables['classes_array'][] = 'media-gallery-view-full';
  }

That was fine, except with the Framework theme. The Framework theme does not print the classes for the node in full view. :/

--------------
What does the selectors do:
The selectors try to find only the media-thumbnails, which are in the current node (full view). So if there is another block with media-thumbnails, then they should not be draggable.

For the final solution, see patch.
Tested with all mentioned themes: Bartik, Adaptive Theme, Framework, Omega, Andromeda, Sky

lsolesen’s picture

Status: Needs review » Fixed

Reviewed and committed.

mrpauldriver’s picture

There doesn't appear to be a dev version for media gallery module.

Any ideas when this will find its way into a beta release?

lsolesen’s picture

i cannot say at the moment. we are working hard. you can help by reviewing other issues.

Status: Fixed » Closed (fixed)

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

mrpauldriver’s picture

I'm using the Dev version from 2012-Sep-25, but unfortunately this bug is not fixed for me.

I am using Omega theme.

Any pointers?

elgandoz’s picture

With omega theme the problem is MG use classes to identify sortables, but omega (and so other themes I think) change these.
Change the _media_gallery_sanitize_ids function in media_gallery.pages.inc in this way:

function _media_gallery_sanitize_ids($prefix, $list) {
  foreach ($list as &$value) {
   // $value = intval(str_replace($prefix, '', $value));
    $value = intval(str_replace('media-gallery-','',str_replace($prefix, '', $value)));
  }
  return $list;
}
elgandoz’s picture

Status: Closed (fixed) » Needs work

As this is still present in the 7.x-1.x-dev of 2012-Oct-09 with omega theme (widely used: October 7, 2012 --> 30,486 ), I'm reopening

moloc’s picture

Status: Needs work » Closed (fixed)

This issue fixed the draggable handler.

Your issue is #1701690: Cannot reorder galleries on the galleries page (SQL error). Therefore i close this again.