Skip to content

Conversation

@selul
Copy link
Contributor

@selul selul commented Dec 4, 2025

This pull request introduces several improvements and bug fixes related to DAM (Digital Asset Management) image handling, unoptimized URL extraction, and test coverage. The main focus is on enhancing the reliability and accuracy of image URL normalization and attachment ID resolution for DAM/offloaded images, as well as improving test stability.

DAM/offload image handling and attachment resolution:

  • Refactored the logic to detect DAM URLs by moving is_dam_url into the Optml_Dam_Offload_Utils trait and updating its usage throughout the codebase for better encapsulation and reuse. [1] [2]
  • Improved the attachment_url_to_post_id method to correctly extract attachment IDs from DAM/offloaded image URLs using a new helper (get_attachement_id_from_optimole_id) that queries the database based on the Optimole ID. [1] [2] [3]

Unoptimized URL extraction and normalization:

  • Enhanced the get_unoptimized_url method to correctly handle uploaded images with /id: patterns, ensuring the original URL is extracted and returned as expected.
  • Updated get_optimized_image_url to always extract the unoptimized URL before rebuilding the Optimole URL, preventing double-optimization issues.

Testing and developer experience:

  • Added comprehensive unit tests for get_unoptimized_url, covering regular, offloaded, custom domain, and edge case URLs to ensure robust behavior.
  • Improved test stability by preventing cache-clearing actions during test runs, avoiding errors from cache compatibility classes.

https://secure.helpscout.net/conversation/3142052654/476408?viewId=2353196

- Added logic to extract the original URL from Optimole URLs in the `get_optimized_image_url` method.
- Moved the `is_dam_url` method to the `Optml_Dam_Offload_Utils` trait for better organization.
- Updated the `Normalizer` trait to handle specific URL patterns.
- Introduced new tests for `get_unoptimized_url` to cover various scenarios, including non-Optimole URLs and edge cases.
- Prevented cache clearing actions during tests to avoid errors related to cache compatibility.

https://secure.helpscout.net/conversation/3142052654/476408?viewId=2353196
@pirate-bot
Copy link
Collaborator

pirate-bot commented Dec 4, 2025

Plugin build for 02ce6f2 is ready 🛎️!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants