WordPress.org

Ready to get started?Download WordPress

Forums

Related Posts Thumbnails
Incompatible with 'WordPress HTTPS (SSL)' (1 post)

  1. Chris_Maes
    Member
    Posted 1 year ago #

    I'm using WordPress 3.5 and the plugins related posts thumbnails and wordpress https (ssl).

    What wordpress https (ssl) does is put https links to images in the posts and when the posts are viewed over non-ssl connections they are renamed to http.

    related posts thumbnails shows default thumbnail for these images as it searches on for the baseurl (http://...)

    I could solve this however by adding a few lines of code. What it basically does is switch http to https and vice versa and do another search in case no images were found in the baseurl. in my case the https://... images are found and the plugin shows the correct http:// image.

    I have posts that were created with and without wordpress https (ssl) and it now works for all images.

    Do you think you could include my code (or something similar) into any next releases?

    if(!isset($matches[1][0])){
    						$debug .= 'No image was found in '.$wud['baseurl'].';';
    						$baseurl=$wud['baseurl'];
    						// switch https for http and vice versa
    						if(strtolower(substr($baseurl,0,5))=='https'){
    							// switch from https to http
    							$baseurl=str_replace('https:', 'http:', $baseurl);
    						}else{
    							// switch from http to https
    							$baseurl=str_replace('http:', 'https:', $baseurl);
    						}
    						$debug .= 'Trying to search again in '.$baseurl.';';
    preg_match_all( '|<img.*?src=[\'"](' . $baseurl . '.*?)[\'"].*?>|i', $post->post_content, $matches);
    					}

    PS: The debug option was VERY helpful, thank you for that!

    http://wordpress.org/extend/plugins/related-posts-thumbnails/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic