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

Check for an existing image before processing media on the target site. #1296

Merged
merged 6 commits into from
Jan 31, 2025

Conversation

iamdharmesh
Copy link
Member

@iamdharmesh iamdharmesh commented Jan 24, 2025

Description of the Change

As reported in #765, when the same image is used in multiple posts and these posts are distributed to connected sites, the media files are imported for each post, creating duplicate copies of the images on the target sites. This PR fixes the media duplication issue by checking for existing media on the target site before creating new media.

Closes #765

How to test the Change

  1. Assign the same image file to multiple posts on the origin site.
  2. Distribute these posts to a subsite (network connection) or external connection.
  3. Verify that there are no duplicate images on the target site and that images are reused in multiple posts.

Changelog Entry

Changed - The default value of the filter dt_sync_media_delete_and_replace has been updated from true to false.
Fixed - Resolved the media duplication issue when the same image is used in multiple posts.

Credits

Props @philbraun @jeffpaul @iamdharmesh

Checklist:

@iamdharmesh iamdharmesh self-assigned this Jan 24, 2025
@github-actions github-actions bot added this to the 2.1.0 milestone Jan 24, 2025
@iamdharmesh iamdharmesh changed the title [WIP] Check for an existing image before processing media on the target site. Check for an existing image before processing media on the target site. Jan 27, 2025
@iamdharmesh iamdharmesh marked this pull request as ready for review January 27, 2025 04:35
@iamdharmesh iamdharmesh requested a review from a team as a code owner January 27, 2025 04:35
@iamdharmesh iamdharmesh requested review from Sidsector9 and removed request for a team January 27, 2025 04:35
@github-actions github-actions bot added the needs:code-review This requires code review. label Jan 27, 2025
Copy link
Collaborator

@peterwilsoncc peterwilsoncc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me and tests well, thanks.

Just a minor note inline to include the data provider param annotations in the test's docblock. Otherwise I think it's good to go.

Copy link
Collaborator

@peterwilsoncc peterwilsoncc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the follow up, this looks good to merge.

@iamdharmesh iamdharmesh merged commit 813961a into develop Jan 31, 2025
18 checks passed
@iamdharmesh iamdharmesh deleted the fix/765 branch January 31, 2025 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs:code-review This requires code review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Media files duplicated after distribution
2 participants