Skip to content
This repository has been archived by the owner on Feb 24, 2021. It is now read-only.

Handle placeholder generation #33

Merged
merged 1 commit into from
Nov 3, 2018
Merged

Conversation

luqmanoop
Copy link
Collaborator

@luqmanoop luqmanoop commented Oct 22, 2018

What does this PR do?

Fixes a bug where a placeholder is being generated for wrong src assumed to be a Cloudinary image.

How to test this PR?

/*
* Before
* Given an image with src other than Cloudinary
* https://cdn.pexels.com/upload/2012/02/10/cloudinary__340.jpg
*/
if (src && src.includes('cloudinary')) { // matches
  ...
}

As stated in Cloudinary documentation here, the best way to test if the image is from Cloudinary is to check in the host

/*
* After
* Given an image with src other than Cloudinary
* https://cdn.pexels.com/upload/2012/02/10/cloudinary__340.jpg
*/
try {
  const srcURL = new URL(src)
  if (srcURL.host.includes('cloudinary')) { // does not match
    ...
  }
} catch(err) {}

…dinary` match in image src

- test for `cloudinary` match in image src host and properly generate
placeholder for cloudinary images
- update broken image src for react/preact in app examples
- keep code DRY
@luqmanoop luqmanoop changed the title properly handle string replace for `clou… Handle placeholder generation Oct 22, 2018
@ooade
Copy link
Owner

ooade commented Oct 22, 2018

Thanks. I'll look into this. It might take a while tho.

@ooade ooade merged commit f475cca into master Nov 3, 2018
@luqmanoop luqmanoop deleted the fix/cloudinary-placeholder branch November 3, 2018 11:44
@luqmanoop
Copy link
Collaborator Author

Thanks for reviewing and merging. Cheers.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants