syamilmj / Aqua-Resizer

Resize WordPress images on the fly
501 stars 204 forks source link

WPML error: Image must be local when enabling "directory for default language" #101

Open PixelbarEupen opened 7 years ago

PixelbarEupen commented 7 years ago

When I enable "directory for default language" in WPML, aq_resize fails to resize images because it can't find the image. The error log says: Aq_Resize.process() error: Image must be local: URL

It is because WPML rewrites the image url tohttp://sitedomain/LANGAUGE_CODE/wp-content/uploads/image.jpg.

I added a small fix in the WPML-Fix in the aq_resize script:

/* WPML Fix */ if ( defined( 'ICL_SITEPRESS_VERSION' ) ){ global $sitepress; if( ICL_LANGUAGE_CODE !== $sitepress->get_default_language() ) { $url = $sitepress->convert_url( $url, $sitepress->get_default_language() ); } } /* WPML Fix */

This solution works for me.

PixelbarEupen commented 7 years ago

Actually i got a better (not perfect) approach:

/* WPML Fix */ if ( defined( 'ICL_SITEPRESS_VERSION' ) ){ $wpml = maybe_unserialize( get_option('icl_sitepress_settings') ); if( ! $wpml['urls']['directory_for_default_language'] ) { global $sitepress; $url = $sitepress->convert_url( $url, $sitepress->get_default_language() ); } } /* WPML Fix */