• I have fix for this issue, which I want to bring it to your attention, and I need you to confirm my proposed fix will not have an unintended consequence I am yet to discover.

    The Details

    I have a WPML site that uses domain mapping. The Spanish and English versions of the site have different root domain names. Domain mapping is provided through a WPML feature that allows different domains to be used for different sites as opposed to the standard set up of different directories, subdomains or query strings for each site.

    The root site is Spanish.
    The secondary site is English.

    Images are not created for the English site. It appears the image resizer is not able to ascertain the URL of feature images because the domain name of the English site is not the same as the domain name of the Spanish site.

    The first time I created a WP Show Posts shortcode for this specific site I used the same shortcode in both En & Es versions of the site. The image src was not found for the En site (that’s pretty much the message in the HTML source). Images did show in the Es site.

    The second time I created a WP Show Posts shortcode I duplicated the (first) Spanish site’s shortcode post then switched to the English site to reconfigure the taxonomy settings. Images still failed to show for the English site.

    The third time I tested WP Show Posts I connected the En and Es translations. Same error. No images shown by WP Show Posts shortcodes in the English version of the site.

    Proposed Fix

    Looking at the WP Show Posts code I can see the below function at the bottom of the inc/image-resizer.php:

    if ( ! function_exists( 'WPSP_Resize' ) ) :
        /**
         * This is just a tiny wrapper function for the class above so that there is no
         * need to change any code in your own WP themes. Usage is still the same :)
         */
        function WPSP_Resize( $url, $width = null, $height = null, $crop = null, $single = true, $upscale = false ) {
            /* WPML Fix */
            if ( defined( 'ICL_SITEPRESS_VERSION' ) ){
                global $sitepress;
                $url = $sitepress->convert_url( $url, $sitepress->get_default_language() );
            }
    
    		/* Jetpack Photon fix */
    		if ( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'photon' ) && function_exists( 'jetpack_photon_url' ) ) {
    			$type = ( $crop ) ? 'resize' : 'fit';
    			$args = array( $type => $width . ',' . $height );
    			return jetpack_photon_url( $url, $args );
    		}
    
            $WPSP_Resize = WPSP_Resize::getInstance();
            return $WPSP_Resize->process( $url, $width, $height, $crop, $single, $upscale );
        }
    endif;

    That WPML fix in that block of PHP is part of the problem. Disabling the fix resolves the issue to allow WP Show posts to display feature images in both En and Es versions of the site.

    I suspect that where domain mapping is used within WPML that the WPML fix is unable to grab the correct details for mapped secondary sites.

    I have used WP Show Posts with other WPML sites that do not use domain mapping. This issue does not exists in these sites.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Lee Hodson (VR51)

    (@leehodson)

    I’ve just noticed that the site error log shows the message:

    WPSP_Resize.process() error: Image must be local

    This message is displayed when WPML compatibility fix is present in the image resizer. Removing that fix solves the issue. All points to the resizer not being bale to establish the correct domain when WPML domain mapping is in use.

    Thread Starter Lee Hodson (VR51)

    (@leehodson)

    This bug still exists in 1.1.3. Deleting the WPML fix resolves the bug.

    Plugin Author Tom

    (@edge22)

    Hi there,

    Sorry for not getting back to you!

    Removing this code fixes the issue?:

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

    Found a similar report here: https://github.com/syamilmj/Aqua-Resizer/issues/104

    Thread Starter Lee Hodson (VR51)

    (@leehodson)

    It does. It appears to only be an issue when domain masking is used to differentiate language versions of a site.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Image Resizer Fails in Some WPML Configurations’ is closed to new replies.