I am in search of a snippet or function that will filter the Embeddedembedded images inside a post to a custom size I have defined in functions.php.
To make Clear Here is the scenario - In a blog Client does not care about the image sizes he insert inside the post usingHere is the scenario:
A client uploads and add media button, so some timesany image size into the_content()
. Sometimes he will upload very large images, and if i use CSS to resize the image it will not always work correctly. So I think If isIs there a way to get the embedded images inand replacing them with a custom size that I have already defined to fit the layout dynamically using Filterthe_content
filter.
Using the below code, I get all the attachments iI have inside the post, and can loop through it,
Now, Isis it possible to displaytake these image attachments, remove them from the_content
, and replace them with a custom sized imagespost thumbnail I've specified in posts, even if uploaded Larger images inside editorfunctions.php.
EDIT:EDIT
summarize as - Search the content for any attachments coming through the_content()To make it more specific, and then display the Custom size versions of those images(those we defined inside functions.php)here is what I have in front end rather showing the original image uploaded.
TO MAKE IT MORE SPECIFIC HERE IS A SAMPLE CODEmind, I am not a PHP geek, I know itthe code is a crapnot correct, but it is just a hint to what iI want,
What itthis should do, is it will return a specified image (ie, themerpro_post_thumbthemerpro_post_thumb
), that is exactly what I want, but the issue with the above code is, it will display only one image from the post, function returnsit should return an array, want to solve that,. The second issue is it will skip out the text inside the post (iI mean paragraphs, etc...).