Home › Forums › Front-end Issues › Attach uploads from post_content to post in frontend › Reply To: Attach uploads from post_content to post in frontend
No there isn’t, and it would be difficult to do so. You would need to parse the HTML in post_content to find the images and the image IDs added to the content preg_match_all() and a regular expression.
Here is an example of an image inserted into content
<img class="alignnone size-medium wp-image-140" src="http://domain.com/wp-content/uploads/2023/03/image.jpg" alt="" width="300" height="169" />
you can see that in the class the image ID of “140” is included.
This has not been tested, but something like might do it.
preg_match_all('/wp-image-(\d+)/', $string, $matches);
And you’re list of ID (as strings) would be found in $matches[1]
.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.