When copying a webpage to my Joomla site, there is a big hassle which is dealing with images. We can easily copy text content and its format but we will have to download the images on the webpage, upload them to my website, and modify lots of the src
attributes.
Because I have a lot of articles to copy, I am thinking to make a plugin so I can just copy the webpage, paste it to the editor, and save without worrying about downloading the images and changing src
manually. I've managed to write a light PHP application(it is a standalone PHP file put in Joomla site's image folder, but it has nothing to do with Joomla) that accepts a folder name and an array of images' original src as POST data, then it will create the folder and directly download images into it(using file_get_content
). So after I copy/paste, the plugins needs to capture the onBeforeSave
(or something like that) event, and retrieve the content's info grabbing each images' link, then send its link along with the article's id(using id as folder name) to my image downloading application.
The problem is, inside a plugin, how to send the POST data? Does joomla provide some function that can handle this? Or I have to use the vanilla PHP way?
public function onBeforeEasyBlogSave($post, $isNew)
{
$folder = $post->id;
$content = $post->content;
imageLinks = getImageLinks($content);
// How do I post $folder and $imageLinks to getImage.php?
}