Make images link to medium or large size — not full - Wordpress Solution
[Solved] - Make images link to medium or large size — not full - Wordpress Solution
Try following codes
Alright, this has been bugging me for quite a while, and I've yet to find a decent answer that doesn't involves tearing up WordPress' core files. How do I make images that are inserted into a post link to the medium or large version, and not the full size? I see two possible solutions — but I'm not clever enough to hack together a plugin. 1) Create a new button under Link URL in the Media/Gallery section that says "Large Size" 2) Filter the function that outputs images in posts to show the medium/large version instead of the full size Other suggestions and solutions are of course just as welcome. Thanks!

Solution - 1

insert this code to functions.php of your theme.

	add_filter('attachment_fields_to_edit',  'medium_attachment_fields_to_edit', 0,  2);
	function medium_attachment_fields_to_edit($fields, $post){
		if (substr($post->post_mime_type,0,5) == 'image'){
			$fields['url']['html'] = str_replace("<button type='button' class='button urlfile'", "<button type='button' class='button urlfile' title='".esc_attr(array_shift( wp_get_attachment_image_src($post->ID, 'medium', false) ))."'>Medium File URL</button>\n<button type='button' class='button urlfile'", $fields['url']['html']);
		return $fields;
added screnshot

Solution - 2

You can made it via CSS file. Look at HTML codes and find your links CLASS, for example: My site Our class is largelink, find it at your CSS and replase how you want. If you need more help please contact with me.

Solution - 3

Not sure what your use is for this but you could just insert a post thumbnail for the post: [[LINK href="http://wpengineer.com/the-ultimative-guide-for-the_post_thumbnail-in-wordpress-2-9/"]]http://wpengineer.com/the-ultimative-guide-for-the_post_thumbnail-in-wordpress-2-9/[[/LINK]] The issue is if you need this to change from large to medium to small size this may be difficult. Often times i have wordpress spit out both images and have jquery hide one or the other thumbnail based on the template. This could also allow you to (further down the line) to build something more complicated. Does that help?

Date: 2022-10-21 05:22:07
Category: Wordpress
More for You