Support

Account

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].