Site logo

Archived topic

GP and WPML multi domain Gp.resize not working as expected

3 replies · Started by Enrico on November 5, 2017

Viewing posts 1–4 of 4

Hello,

in the aq_resizer.php in the GP Pro/blog module, at line 229 there is this part:

if ( defined( 'ICL_SITEPRESS_VERSION' ) ){
    global $sitepress;
    $url = $sitepress->convert_url( $url, $sitepress->get_default_language() );
}

Problem: On my site we use wpml with different domains, and if this function runs, it replaces all the attachment sources with the host from the default language. If this happens, I get the GP_Resize.process() error: Image must be local error, because the resizer checks on line 103 if the upload url is in the image url:

if ( false === strpos( $url, $upload_url ) )
    throw new GP_Exception('Image must be local: ' . $url);

In my case, the best would be if GP would not convert the url at all, because the images can just as well be served through the language domain. I changed the url convertion part like this:

if ( defined( 'ICL_SITEPRESS_VERSION' ) ){
    global $sitepress;
    $wpml_negotiation_type = apply_filters('wpml_setting',false, 'language_negotiation_type' ) ;            
    if ( $wpml_negotiation_type != 2) {
        $url = $sitepress->convert_url( $url, $sitepress->get_default_language() );
    }
}

That means I check if wpml is run on different domains for different languages (negotiation type is 2) and only convert only if not.

1) I am not sure why this conversion takes place to begin with. Maybe there is something special about my site, but I don't understand this step.
2) If this is somehow necessary for other (normal?) setups, what would be the right approach to overwrite this function, so my fix does not get patched away in the future?

Thanks for your help

Hi,
just installed the new update (1.51) and the issue of not showing the featured post images with wpml on different domains is gone. Worked right out of the box after the update.

Thanks

Great news - thanks for letting me know :)

This archived topic is closed to new replies.