Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'acf_qtranslate_acf_5_image' does not have a method 'wp_prepare_attachment_for_js' #718

Closed
fabienlege opened this issue Aug 7, 2019 · 27 comments
Labels
bug Something isn't working, reproducible module: ACF Integration with ACF

Comments

@fabienlege
Copy link

Wordpress media library not working with build-in acf image field.
When click on "select image", media library open, but show no image nor error.

In php log, we can see this error : PHP Warning: call_user_func_array() expects parameter 1 to be a valid callback, class 'acf_qtranslate_acf_5_image' does not have a method 'wp_prepare_attachment_for_js' in /var/www/html/cauterets/wp-includes/class-wp-hook.php on line 286

I use the last version of your plugin and acf

@Tusko
Copy link
Contributor

Tusko commented Aug 8, 2019

+1

1 similar comment
@WIDESRL
Copy link

WIDESRL commented Aug 8, 2019

+1

@fminov
Copy link

fminov commented Aug 9, 2019

Hi,

Exact same problem here, site with 1600+ images, seems like an ajax call is made for each image before the result is displayed in media library. So 1600+ ajax calls before seeing images in the library.
Same error in log Fabien posted, repeated for each ajax call (fast growing log !).
Media Library with Real Media Library plugin, last version of qtranslate-xt.

Thanks for your help, please tag this as bug.

@Tusko
Copy link
Contributor

Tusko commented Aug 10, 2019

@fminov Media library by default doesn't work.

@fminov
Copy link

fminov commented Aug 12, 2019

@Tusko hi, indeed, same problem with Real Media Library enabled or with stock Media Library

@herrvigg
Copy link
Collaborator

Wordpress media library not working with build-in acf image field.

hello,
this looks related to ACF, i don't see why this would be a problem with qTranslate especially since you are using a standard ACF image field! I could understand if you were using a qTranslate image field but not really here. What happens if you disable qTranslate-XT?

@gab1982
Copy link

gab1982 commented Aug 12, 2019

Wordpress media library not working with build-in acf image field.

hello,
this looks related to ACF, i don't see why this would be a problem with qTranslate especially since you are using a standard ACF image field! I could understand if you were using a qTranslate image field but not really here. What happens if you disable qTranslate-XT?

Yes but it is ok when qTranslate-XT is disabled as I mentioned in issue 719, so somehow they must be related, I was using the ACF gallery, going back to the previous version of ACF (5.8.2) fixed the issue for me.

@herrvigg
Copy link
Collaborator

Mmmm that sounds strange but let's see.

  1. Does this happen if you disable ACF and keep qTranslate-xt?

  2. With both ACF and qTranslate-XT enabled, can you try just to disable manually the ACF module in qTranslate-XT? Either rename qtranslate-xt/modules/acf to something else (e.g. acf-disabled), or comment the acf entry in modules/qtx_modules_handler.php. This will just disable temporarily the specific integration part with ACF (just work on test posts under that time).

@gab1982
Copy link

gab1982 commented Aug 12, 2019

Mmmm that sounds strange but let's see.

  1. Does this happen if you disable ACF and keep qTranslate-xt?
  2. With both ACF and qTranslate-XT enabled, can you try just to disable manually the ACF module in qTranslate-XT? Either rename qtranslate-xt/modules/acf to something else (e.g. acf-disabled), or comment the acf entry in modules/qtx_modules_handler.php. This will just disable temporarily the specific integration part with ACF (just work on test posts under that time).
  1. No it seems ok if I disable ACF
  2. If I rename the acf folder to something else, it seems to fix the issue

thanks

@herrvigg
Copy link
Collaborator

OK i found it

add_filter('wp_prepare_attachment_for_js', array($this, 'wp_prepare_attachment_for_js'), 10, 3);

As a quick workaround fix you could just comment this line. For the correct fix one should look at the new acf_image_field. This means they have changed it in the last version (5.8.3) and this wp_prepare_attachment_for_js function has disappeared. If it works with 5.8.2 this is really bad from ACF as a patch release should not break the current interface!

Btw where did you get ACF 5.8.3? Maybe it's only for the PRO version. For the free it's still 5.8.2 even on github.

@gab1982
Copy link

gab1982 commented Aug 12, 2019

OK i found it

add_filter('wp_prepare_attachment_for_js', array($this, 'wp_prepare_attachment_for_js'), 10, 3);

As a quick workaround fix you could just comment this line. For the correct fix one should look at the new acf_image_field. This means they have changed it in the last version (5.8.3) and this wp_prepare_attachment_for_js function has disappeared. If it works with 5.8.2 this is really bad from ACF as a patch release should not break the current interface!

Btw where did you get ACF 5.8.3? Maybe it's only for the PRO version. For the free it's still 5.8.2 even on github.

Thanks for the quick reply and quick fix, yes its not good, I have the pro version, hopefully they release a fix soon.

@fminov
Copy link

fminov commented Aug 12, 2019

@herrvigg Hi, thanks a lot for the quick fix, it works perfectly !

@herrvigg
Copy link
Collaborator

Nice to hear! However i'm not sure about the impact, disabling this may have some side effects for that particular field.

Could someone having 5.8.3 send the new file holding the acf_image_field class? So we can see what they have done there. Some of the PRO users should also open a ticket on their side at least to tell them they broke the interface.

@fminov
Copy link

fminov commented Aug 12, 2019

Is there any simple way to contact you privately for this ?

Note : previously I tried ACF 5.8.2 Pro and it didn't work any better.

@gab1982
Copy link

gab1982 commented Aug 12, 2019

acf_image_field

I searched the plugin for this but no where to be found.

@herrvigg
Copy link
Collaborator

Is there any simple way to contact you privately for this ?

<my-nickname> at gmail.com

Note : previously I tried ACF 5.8.2 Pro and it didn't work any better.

This sounds weird, in contradiction with what @gab1982 mentioned earlier :-/
Also, see the code of ACF 5.8.2 below. the function is there and i don't see how it would be different in the PRO version but please check below.

I searched the plugin for this but no where to be found.

We derive from acf_image_field so this has to be there otherwise you'd have an error. But maybe the have done something special with the Pro release.

Here is the class and the concerned function in 5.8.2 Free: acf/includes/fields/class-acf-field-image.php

https://github.com/AdvancedCustomFields/acf/blob/f745d197118d1396a45084ddad6299abdf78d72d/includes/fields/class-acf-field-image.php#L396

Now to come up with a fix one should look at the diff 5.8.3 PRO vs 5.8.2 PRO.
And maybe the diff 5.8.2 Free vs 5.8.2 PRO (just about this function).

@herrvigg herrvigg added bug Something isn't working, reproducible plugin: others Concerns integration with other plugins labels Aug 13, 2019
@herrvigg
Copy link
Collaborator

All right, tthey simply removed the function from 5.8.3 and it's not documented in the release notes. But it looked like a hacky hook in the first place:

*  wp_prepare_attachment_for_js
	*
	*  this filter allows ACF to add in extra data to an attachment JS object
	*  This sneaky hook adds the missing sizes to each attachment in the 3.5 uploader. 
	*  It would be a lot easier to add all the sizes to the 'image_size_names_choose' filter but 
	*  then it will show up on the normal the_content editor

So we can certainly assume it is safe to ignore it. Maybe they fixed something in WP core that allows to avoid this and i don't expect it to see it back again. I'll find a way to have a better check in QT-XT. For now the best temporary fix is simply to comment the line in the ACF module as described earlier.

@herrvigg
Copy link
Collaborator

Fix merged in master.

@herrvigg
Copy link
Collaborator

@fminov it is really surprising it didn't work when you moved back to ACF 5.8.2 because the original function is there. Maybe you had some cache working or something else happened when switching the versions.

@fminov
Copy link

fminov commented Aug 14, 2019

@herrvigg thanks a lot for your research !
Maybe I had the problem with 5.8.2 because of cache yes, it's possible.

@GersonM
Copy link

GersonM commented Aug 29, 2019

Hi,

there are no update yet but the fix works fine.

I found the file here
wp-content/plugins/acf-qtranslate/src/acf_5/fields

Regards!.

@netgfx
Copy link

netgfx commented Jul 5, 2020

Hello is this fixed on some latest version? I have 5.8.11 (pro) and it is still affecting media library.

@herrvigg
Copy link
Collaborator

herrvigg commented Jul 7, 2020

@netgfx this has been fixed long ago. What qTranslate-XT are you using?

@netgfx
Copy link

netgfx commented Jul 7, 2020

@herrvigg Well that's the thing I have qtranslate-X (the site already had it installed when I picked it up), I know its long abandoned, do you think it is fairly save to replace it with qtranslate-xt or would there be lots of issues?
I managed to fix it by commenting the acf_image_field but its a hacky solution.

@herrvigg
Copy link
Collaborator

herrvigg commented Jul 7, 2020

@netgfx why do you still use qTranslate-X? There is no reason using an obsolete plugin. If you read the main README you will find the answer to your questions.

@yokotsumo
Copy link

ACF: 5.8.12
Qtranslate-XT : 3.6.0

I have the same problem and the above solution is not working.

@herrvigg
Copy link
Collaborator

You have all the history in this thread. Fixed in 3.6.2 almost one year ago... why are you using such an old version? Last release is 3.8.1.

@herrvigg herrvigg added module: ACF Integration with ACF and removed plugin: others Concerns integration with other plugins labels Dec 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working, reproducible module: ACF Integration with ACF
Projects
None yet
Development

No branches or pull requests

9 participants