WordPress.org

Ready to get started?Download WordPress

Forums

WordPress Related Posts
the_post_thumbnail('medium'); instead of the default 150x150 in modern layout? (3 posts)

  1. jeriksson
    Member
    Posted 8 months ago #

    Hi,

    How can i modify the code to the_post_thumbnail('medium'); instead of getting the default 150x150 thumbnail from wordpress?

    Any ideas?

    https://wordpress.org/plugins/wordpress-23-related-posts-plugin/

  2. jeriksson
    Member
    Posted 8 months ago #

    is this the function that gets thumbnail from posts?

    function wp_rp_upload_attachment($url, $post_id) {
    	/* Parts copied from wp-admin/includes/media.php:media_sideload_image */
    
    	include_once(ABSPATH . 'wp-admin/includes/file.php');
    	include_once(ABSPATH . 'wp-admin/includes/media.php');
    	include_once(ABSPATH . 'wp-admin/includes/image.php');
    
    	$tmp = download_url($url);
    	preg_match( '/[^\?]+\.(jpe?g|jpe|gif|png)\b/i', $url, $matches);
    	$file_array['name'] = sanitize_file_name(urldecode(basename($matches[0])));
    
    	$file_array['tmp_name'] = $tmp;
    	if (is_wp_error($tmp)) {
    		@unlink($file_array['tmp_name']);
    		return false;
    	}

    I can't find the call "the_post_thumbnail" anywhere in the code, i'm guessing it falls back on the built in code? is there any simple way to modify this to get the medium or large size thumbnail from post instead of the default one? i can do the css work for template easily, i just need help getting the code to grab the correct thumbnail.

  3. PetraP
    Member
    Plugin Author

    Posted 8 months ago #

    Hey jeriksson.

    thanks for reaching out - I'll gladly help!
    You don't need to change any functions or files. Please go to plugin settings->"Advanced settings"->"Customize" and tick the box next to "Enable custom CSS". You need to tick the box next to the "Use Custom Size Thumbnails" also (enter the dimensions you wish for the thumbnails to be). Now in the custom CSS "box" add e.g. width:350px !important; and height:150px !important; between ul.related_post li img {..here...} brackets. Also, add width:350px !important; between ul.related_post li {....here...}. Don't forget to save the changes. Check the screenshot for easier navigation.

    Everything put together should look like this:`

    .related_post_title {
    }
    ul.related_post {
    }
    ul.related_post li {
    width:350px !important;
    }
    ul.related_post li a {
    }
    ul.related_post li img {
    width:350px !important;
    height:150px !important;
    }

    Hope this helps!

    Please let me know how it goes,
    Petra

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.