We are experiencing some strange behavior after updating to Manual Crop version 7.x-1.4. When clicking the "Edit Media" button on the media file selector widget we would expect the Media modal popup window to appear. However we get an AJAX error mentioning the callback path could not be found.

So i started investigating why this isn't working and by accident found out that the same button was working in the English administration interface which has 'en' as a prefix, our default language is Dutch. So i compared the URI's that are used in both languages.

With the Dutch administration interface (no prefix) the edit URI is:

/media/10815/edit/nojs/media/10808/edit/nojs/node/blog_article/field_blog_image

With the English administration interface ('en' as prefix) the edit URI is:

/en/media/10815/edit/nojs/en/media/10808/edit/nojs/node/blog_article/field_blog_image

The first URI returns a page not found, the second URI is working just fine. After a bit of debugging i found out the URI without the first 'en' prefix was also working:

/media/10815/edit/nojs/en/media/10808/edit/nojs/node/blog_article/field_blog_image

I can actually replace 'en' in the above link with the prefix for any other active language and it will also work.

The URI for the edit button is modified by the 'manualcrop_media_element_process()' function where '/media/10815/edit/nojs/' is modified to the links you see above.

So this can either be an issue with the Manual Crop module or the Media module but i have no idea where to look next.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Matthijs’s picture

Hi Eric,

Thanks for your report! This looks like a weird issue, my first guess would be that it's a problem with the Media module, but I should investigate it to give you a final/good answer...

Instead of spending my time on this, I would like to ask you if you mind updating to the last dev version? I've rewritten the link altering to use query variables instead of appending addition url elements, so this might fix your issue.

Could you give it a try and let me know?

Thanks!

Matthijs

ericmulder1980’s picture

Hi Martijn,

Thank you so much for answering so quickly.

As you've asked i have installed the latest dev version of manual crop and tried again. Unfortunately the error is still the same, the URL for the Edit media button did change however

/media/898/edit/ajax/media/898/edit/nojs%3Fmanualcrop%5Bentity_type%5D%3Dnode%26manualcrop%5Bbundle%5D%3Dpage%26manualcrop%5Bfield_name%5D%3Dfield_page_attachment

Hope this helps.

ericmulder1980’s picture

So i've tested some more and checked the part where the edit link is modified.

As far as i can see this is the URL you want

http://www.example.com/media/[file_id]/edit/nojs?[parameters]

With the current modifications you get a duplicate entry of the "/media/[file_id]/edit/nojs" part.

So if you change

$element['edit']['#href'] .= url('media/' . $element['fid']['#value'] . '/edit/nojs', array('query' => $data));

to

$element['edit']['#href'] = url('media/' . $element['fid']['#value'] . '/edit/nojs', array('query' => $data, 'absolute' => TRUE));

it should give you the URL you are looking for.

ericmulder1980’s picture

Status: Active » Needs review
FileSize
0 bytes

Added a patch to create the situation mentioned in previous post. I hope it's the proper solution to this problem.

ericmulder1980’s picture

Previous patch did not upload correctly.

Matthijs’s picture

Status: Needs review » Fixed

Hi Eric,

Thanks a lot for your work on this! The I've tested and applied your patch, the ".=" was a typo, odd I didn't notice it before (everything worked fine here)...

Thanks again!

Matthijs

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

Dutch => English