protected function getImage($keyImg, $sizeW, $sizeH = false)
    {
        $sizeH = ($sizeH) ? $sizeH : $sizeW;
        // fetch local avatar from meta and make sure it's properly ste
        $local_avatars = get_user_meta($this->ID, $keyImg, true);
        if (empty($local_avatars['full'])) {
            return '';
        }
        // generate a new size
        if (!array_key_exists($sizeW, $local_avatars)) {
            $local_avatars[$sizeW] = $local_avatars['full']; // just in case of failure elsewhere
            $upload_path = wp_upload_dir();
            // get path for image by converting URL, unless its already been set, thanks to using
            // media library approach
            if (!isset($avatar_full_path)) {
                $avatar_full_path = str_replace($upload_path['baseurl'], $upload_path['basedir'],
                    $local_avatars['full']);
            }
            // generate the new size
            $editor = wp_get_image_editor($avatar_full_path);
            if (!is_wp_error($editor)) {
                $resized = $editor->resize($sizeW, $sizeH, true);
                if (!is_wp_error($resized)) {
                    $dest_file = $editor->generate_filename();
                    $saved = $editor->save($dest_file);
                    if (!is_wp_error($saved)) {
                        $local_avatars[$sizeW] = str_replace($upload_path['basedir'], $upload_path['baseurl'],
                            $dest_file);
                    }
                }
            }
            // save updated avatar sizes
            update_user_meta($user_id, $keyImg, $local_avatars);
        }
        if ('http' != substr($local_avatars[$sizeW], 0, 4)) {
            $local_avatars[$sizeW] = home_url($local_avatars[$sizeW]);
        }
        return esc_url($local_avatars[$sizeW]);
    }
protected function getImage($keyImg, $sizeW, $sizeH = false)
    {
        $sizeH = ($sizeH) ? $sizeH : $sizeW;
        // fetch local avatar from meta and make sure it's properly ste
        $local_avatars = get_user_meta($this->ID, $keyImg, true);
        if (empty($local_avatars['full'])) {
            return '';
        }
        // generate a new size
        if (!array_key_exists($sizeW, $local_avatars)) {
            $local_avatars[$sizeW] = $local_avatars['full']; // just in case of failure elsewhere
            $upload_path = wp_upload_dir();
            // get path for image by converting URL, unless its already been set, thanks to using
            // media library approach
            if (!isset($avatar_full_path)) {
                $avatar_full_path = str_replace($upload_path['baseurl'], $upload_path['basedir'],
                    $local_avatars['full']);
            }
            // generate the new size
            $editor = wp_get_image_editor($avatar_full_path);
            if (!is_wp_error($editor)) {
                $resized = $editor->resize($sizeW, $sizeH, true);
                if (!is_wp_error($resized)) {
                    $dest_file = $editor->generate_filename();
                    $saved = $editor->save($dest_file);
                    if (!is_wp_error($saved)) {
                        $local_avatars[$sizeW] = str_replace($upload_path['basedir'], $upload_path['baseurl'],
                            $dest_file);
                    }
                }
            }
            // save updated avatar sizes
            update_user_meta($user_id, $keyImg, $local_avatars);
        }
        if ('http' != substr($local_avatars[$sizeW], 0, 4)) {
            $local_avatars[$sizeW] = home_url($local_avatars[$sizeW]);
        }
        return esc_url($local_avatars[$sizeW]);
    }
protected function getImage ( $ keyImg , $ sizeW , $ sizeH = false ) { $ sizeH = ( $ sizeH ) ? $ sizeH : $ sizeW ; // fetch local avatar from meta and make sure it's properly ste $ local_avatars = get_user_meta ( $ this -> ID , $ keyImg , true ) ; if ( empty ( $ local_avatars [ 'full' ] ) ) { return '' ; } // generate a new size if ( ! array_key_exists ( $ sizeW , $ local_avatars ) ) { $ local_avatars [ $ sizeW ] = $ local_avatars [ 'full' ] ; // just in case of failure elsewhere $ upload_path = wp_upload_dir ( ) ; // get path for image by converting URL, unless its already been set, thanks to using // media library approach if ( ! isset ( $ avatar_full_path ) ) { $ avatar_full_path = str_replace ( $ upload_path [ 'baseurl' ] , $ upload_path [ 'basedir' ] , $ local_avatars [ 'full' ] ) ; } // generate the new size $ editor = wp_get_image_editor ( $ avatar_full_path ) ; if ( ! is_wp_error ( $ editor ) ) { $ resized = $ editor -> resize ( $ sizeW , $ sizeH , true ) ; if ( ! is_wp_error ( $ resized ) ) { $ dest_file = $ editor -> generate_filename ( ) ; $ saved = $ editor -> save ( $ dest_file ) ; if ( ! is_wp_error ( $ saved ) ) { $ local_avatars [ $ sizeW ] = str_replace ( $ upload_path [ 'basedir' ] , $ upload_path [ 'baseurl' ] , $ dest_file ) ; } } } // save updated avatar sizes update_user_meta ( $ user_id , $ keyImg , $ local_avatars ) ; } if ( 'http' != substr ( $ local_avatars [ $ sizeW ] , 0 , 4 ) ) { $ local_avatars [ $ sizeW ] = home_url ( $ local_avatars [ $ sizeW ] ) ; } return esc_url ( $ local_avatars [ $ sizeW ] ) ; }
Get the image

@param string $keyImg Key image
@param int $sizeW weight
@param int $sizeH height
@return string URL to the image
Get the image