Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PRO] Auto-delete featured image after a number of days when post is deleted #827

Closed
AndreeaCristinaRadacina opened this issue Nov 18, 2023 · 19 comments · Fixed by #1043
Closed
Assignees
Labels
customer report Indicates the request came from a customer. doc-needed This issue requires documentation updates or additions once it has been completed. new feature Request for a new feature or functionality to be added to the project.
Milestone

Comments

@AndreeaCristinaRadacina
Copy link

AndreeaCristinaRadacina commented Nov 18, 2023

What problem does this address?

EDIT by Vytis:

To me it makes sense to have a checkbox to delete associated images if they have auto deletion of posts configured. Basically, what is mentioned above in Irinel's comment from the user suggestion. If posts aren't configured for auto deletion I don't see a reason images should be deleted as well.

A user asked if we can create a new option for the auto-deleting feature imaged after a certain period because they occupy a lot of space.

Ref: https://secure.helpscout.net/conversation/2425773133/393344?folderId=212385

What is your proposed solution?

Within the general feed settings inside the import, under Auto-Delete, consider adding a new section where users can specify the number of days before the featured image of the posts from that particular import is automatically deleted. Similarly, this setting can be implemented in Feedzy > Settings, providing users with the flexibility to configure this globally or on an individual basis per import.

We can also have a similar approach as we have in Visualizer - https://s3.amazonaws.com/helpscout.net/docs/assets/55192029e4b0221aadf23f55/images/61606f5312c07c18afddbb79/file-FqGbpe8kvS.png

Will this feature require documentation? (Optional)

Yes, it requires documentation.

@AndreeaCristinaRadacina AndreeaCristinaRadacina added the new feature Request for a new feature or functionality to be added to the project. label Nov 18, 2023
@pirate-bot pirate-bot added customer report Indicates the request came from a customer. doc-needed This issue requires documentation updates or additions once it has been completed. labels Nov 18, 2023
@vytisbulkevicius
Copy link
Contributor

@AndreeaCristinaRadacina,

We won't be implementing this now as I don't see this as a feature many would benefit from (because it's not fine to have missing images even for older posts, IMO) but you can suggest user the external image URL function:
image

@irinelenache
Copy link

irinelenache commented Mar 20, 2024

+1 https://secure.helpscout.net/conversation/2544820375/410262/?folderId=212385

"If I can suggest some details on this feature-request: maybe a checkbox that states something like Also remove media associated with deleted posts. It is a simple on/off checkbox that will also trigger imported media removal. A security check that might be performed before actually deleting the media is confirming it is associated solely with the post being deleted (since it is added to the media library, it is possible someone in the meantime associated the imported media with another post)."

@vytisbulkevicius vytisbulkevicius added this to the Feedzy 5.0 milestone Nov 24, 2024
@vytisbulkevicius vytisbulkevicius changed the title Auto-delete featured image after a number of days Auto-delete featured image after a number of days when post is deleted Dec 4, 2024
@vytisbulkevicius vytisbulkevicius changed the title Auto-delete featured image after a number of days when post is deleted [PRO] Auto-delete featured image after a number of days when post is deleted Dec 5, 2024
@vytisbulkevicius
Copy link
Contributor

@girishpanchal30, we planned to have this part of Feedzy release if we have development time left.
Let me know how complicated you see this implementation.

The idea is to delete images if a post is deleted when they have it set up to be deleted after particular amount of days:
Image

Also, it should only delete an image if it is attached to a single post so there aren't other posts left without image after it is deleted.

If you see this complicated or could lead to introducing bugs we might leave it out.

@girishpanchal30
Copy link
Contributor

@vytisbulkevicius

If you see this complicated or could lead to introducing bugs we might leave it out.

Implementing the thumbnail image functionality is straightforward and should not cause any issues. However, retrieving and deleting attached media from the post_content will take more time.

Should I implement it for the thumbnail image only? Please let me know.

Thanks!

@vytisbulkevicius
Copy link
Contributor

@girishpanchal30,

This is only about featured image as if image is used in the description/content of the item we don't import such images to WordPress, we use external URLs to reference them, the same image URL as it is is original XML Feed.

Or have you mentioned this because existing image that was imported as featured image can be later used in some other post in the content of it? In such case it is fine, we shouldn't bother about this IMO.

It's important to make this an optional functionality, when Auto-delete is set up it should be a checkbox that you need to check to also delete imported featured images attached.

@girishpanchal30 girishpanchal30 linked a pull request Dec 25, 2024 that will close this issue
6 tasks
@girishpanchal30
Copy link
Contributor

@vytisbulkevicius Thank you for the clarification!

I’ve implemented it in the following PRs. Please review them along with the build zip and let me know if you encounter any issues.
Pro: https://github.com/Codeinwp/feedzy-rss-feeds-pro/pull/809
Lite: #1043

Thanks!

@vytisbulkevicius
Copy link
Contributor

@girishpanchal30,

Let's remove this separator as it will be clearer that these features are connected:
Image
And reduce padding between them so it looks like this:
Image

btw, I set it up for testing but need to wait at least a day to see if images get deleted. Do you have a way that you can recommend to trigger it manually?

@girishpanchal30
Copy link
Contributor

@vytisbulkevicius

Let's remove this separator as it will be clearer that these features are connected:

Done!

btw, I set it up for testing but need to wait at least a day to see if images get deleted. Do you have a way that you can recommend to trigger it manually?

After importing the posts, you can update the post dates to a past date and then trigger the import job.

Image

@vytisbulkevicius
Copy link
Contributor

Thanks @girishpanchal30 but this method didn't work for me, unfortunately. Does it work for you?

I will see the real scenario soon today if it will delete the posts and images, but changing the data to the past and triggering the import didn't delete either the posts or their images.

Screen recording: https://vertis.d.pr/v/A45GGr

@girishpanchal30
Copy link
Contributor

girishpanchal30 commented Dec 27, 2024

Thanks @girishpanchal30 but this method didn't work for me, unfortunately. Does it work for you?

@vytisbulkevicius Apologies for not mentioning how to trigger the import job earlier. The auto-delete feature work with a cron job. You need to trigger the Feedzy cron job, and it should work as expected.

@vytisbulkevicius
Copy link
Contributor

@girishpanchal30, thanks for clarifying, however, with this PR #1043 there seems to be an issue of how cron works.

When you create import it shows that it will be run in almost a month only:
Image

Even though Feedzy cron shows that it will run in a hour:
Image

But it doesn't run after an hour passes. Also, if I manually trigger feedzy_cron:
Image

It doesn't trigger the import job.

@girishpanchal30
Copy link
Contributor

@girishpanchal30, thanks for clarifying, however, with this PR #1043 there seems to be an issue of how cron works.

In this PR, I haven't made any changes related to cron jobs. I've been using WP-CLI to trigger the cron job locally.

I think this will be help you - https://github.com/Codeinwp/feedzy-rss-feeds-pro/issues/572#issuecomment-2547557668

Thanks

@vytisbulkevicius
Copy link
Contributor

@girishpanchal30,

In current production live version of the plugin this problem doesn't exist. An import created by default without changing any settings is set to be run every hour:
Image

also, Running feedzy_cron triggers the import.

@girishpanchal30
Copy link
Contributor

@vytisbulkevicius I believe it's displaying the wrong time after this change. - 48fa552

@vytisbulkevicius
Copy link
Contributor

@HardeepAsrani, can you check?

@girishpanchal30
Copy link
Contributor

@HardeepAsrani Could you please review this patch? It might resolve the issue.

@HardeepAsrani
Copy link
Member

@girishpanchal30 Thanks for the catch, can you create the PR with that?

@girishpanchal30
Copy link
Contributor

@HardeepAsrani I've opened a new PR - #1047, please review it

@vytisbulkevicius
Copy link
Contributor

Tested and everything works good now. I confirmed that posts get deleted and featured images as well. Also, if same featured image is attached to another post, featured image is not deleted, just the post.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer report Indicates the request came from a customer. doc-needed This issue requires documentation updates or additions once it has been completed. new feature Request for a new feature or functionality to be added to the project.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants