I am currently writing phpNuke import Wrdpress plug-in. I have a problem with importing posts with images:
+ I already had written a routine which extracts image tag text and images from source post HTML
- I need to replace
img tags with the ones imported to wordpress media library.
phpNuke post content:
...bla bla... <img src="http://external.site.com/images/image321.jpg"> bla bla...
should be translated to wordpress into something like this:
...bla bla... <img src="http://mysite.com/wp-content/uploads/506_large-127x130.jpg"> bla bla...
I had found a wordpress function media_sideload_image which according to description imports image from given URL into a library and attaches it to the post with given id... But to replace image tag with new I need to:
- insert post with wp_insert_post and save post id
- use media_sideload_image to import and receive image tag
srcin post html
- update post with wp_update_post
This leads to duplicating post data (adding extra revision).
My questions are:
- Is there any way to add image to Wordpress post in more straightforward way? (without double posting)
- Is the linkage of image to post obligatory?