By Christopher Ambler on Monday, 07 November 2022
Posted in EasyBlog
Replies 3
Likes 0
Views 426
Votes 0
I have confirmed that trashing a post and then emptying the trash leaves the post cover and any images (and various sizes) undeleted.

I have to go into /images/easblog_images, find them, and delete them by hand if I want them gone.

I expect trashing a post should also delete the images, as they're what takes up so much space.

Please advise.
Unfortunately, it is not possible to automatically remove the associated image that you added to the blog post because these media images might be used for other blog posts.

Imagine if the user deletes a blog post on the site, the system needed to scan through all the existing blog posts(e.g. more than 5000 blog posts) and see if this single image whether used for other blog posts or not while will impact the site performance issue.
·
Monday, 07 November 2022 12:12
·
0 Likes
·
0 Votes
·
0 Comments
·
I have no users. Just me. And I don't share images between blog posts for just this reason.

My site generates 13 blog posts PER DAY. After a year, they really need to be trashed or my costs for storage go through the roof.

I've written a cron job to trash posts older than a year and then empty the trash.

But the images HAVE TO GO. Otherwise it just costs too much!

If this could cause harm, then an option to delete or not delete images should be available, as there are many customers who need to delete images when posts are also deleted. Make the default to NOT delete, so as to not inadvertently harm anyone, but leaving the images behind when a post is deleted is REALLY BAD. This way, you don't have to do that big search. Either delete or not, at the customer's choice.
·
Monday, 07 November 2022 12:18
·
0 Likes
·
0 Votes
·
0 Comments
·
If this could cause harm, then an option to delete or not delete images should be available, as there are many customers who need to delete images when posts are also deleted. Make the default to NOT delete, so as to not inadvertently harm anyone, but leaving the images behind when a post is deleted is REALLY BAD. This way, you don't have to do that big search. Either delete or not, at the customer's choice.

If we add an option to allow the site blogger to delete images (show a checkbox confirmation) when the blogger decides to delete a blog post on the site, then this will be a high risk for those sites that have multiple bloggers because the blogger does not know how many images they add into their blog post, if the blogger accidentally ticks the checkbox (delete images) then all these images can't be restored back if another blog post still using it.

And I assume that you will gonna said that if add a check during deleting images process if these images really use for other blog posts or not, then this will fall back to what we are concerned about the big search performance issue.

However, the current behavior is when a post is deleted, the files will be relocated to the user's directory instead.

For example:
1. If you upload a post cover image directly when you click the "upload" button under the post cover dropdown, it will store this media file into this path "/images/easyblog_articles/blogID"

2. If the post is deleted, the system will relocate this "/images/easyblog_articles/blogID" blog id folder to the "/images/easblog_images/BlogTitle" new directory folder.

If you would like to delete a post while deleting the uploaded article image (without upload through the media manager), you can create a plugin that hooks to the event onAfterEasyBlogDelete. Then in your plugin's method, you just need to run the following code:


public function onAfterEasyBlogDelete($blog)
{
require_once(JPATH_ADMINISTRATOR . '/components/com_easyblog/includes/mediamanager/mediamanager.php');

$uri = 'post:' . $blog->id;
$path = EBMM::getPath($uri);

if (JFolder::exists($path)) {
JFolder::delete($path);
}
}


And for now, you can manually access this directory folder "/images/easblog_images/" and see if that folder is about your post title name, then you can delete it manually for now.
·
Monday, 07 November 2022 16:44
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post