[ad_1]
Hello,
I have a routine that uploads multiple images in wordpress, they are not showed in the media library because they are not registered. Is there a way using API? I see there are plugins but I need to schedule and don’t want to use one.
Thank you
[ad_2]
Might require some custom coding and a CRON schedule / Scheduled action, which might make it possible. In that case i’d suggest using a temporary / landing folder for the images, and then have the CRON task setup the data in the database, and move the file upon completion, to avoid potential mixups in the wp_content folder (or wherever the images might be stored on the server).
This function should handle most of the serverside tasks for registering the file:
[https://developer.wordpress.org/reference/functions/media_handle_sideload/])
Alongside with this:
[https://developer.wordpress.org/reference/functions/wp_insert_attachment/])
As seen here in an example:
[https://rudrastyh.com/wordpress/how-to-add-images-to-media-library-from-uploaded-files-programmatically.html])