I'm using the classic editor and here are my default settings for images:
In a post, I want all inserted images to be linked to the medium size URL instead of the full sized URL, which appears to be how WP sets it when choosing link to 'Media File'.
Ideally, I want a way to set it for existing and future posts. So far I've found 2 possible ways:
The
image_send_to_editor
filter: Istr_replace
the$url
with the medium size URL. This works for future images that are added to the posts but not for existing images.The
the_content
filter: This would work for existing posts but I'm not sure if I should go with this.
Is there a better approach out there, and which do you recommend?
I'm using the classic editor and here are my default settings for images:
In a post, I want all inserted images to be linked to the medium size URL instead of the full sized URL, which appears to be how WP sets it when choosing link to 'Media File'.
Ideally, I want a way to set it for existing and future posts. So far I've found 2 possible ways:
The
image_send_to_editor
filter: Istr_replace
the$url
with the medium size URL. This works for future images that are added to the posts but not for existing images.The
the_content
filter: This would work for existing posts but I'm not sure if I should go with this.
Is there a better approach out there, and which do you recommend?
Share Improve this question edited Jul 5, 2019 at 8:15 sgro asked Jul 4, 2019 at 18:29 sgrosgro 1012 bronze badges1 Answer
Reset to default 0You can use wp_get_attachment_link(), function if you pass the size argument as medium you will get the medium size image link.
https://codex.wordpress/Function_Reference/wp_get_attachment_link
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745344129a4623465.html
评论列表(0条)