pimg icon indicating copy to clipboard operation
pimg copied to clipboard

Accept src as array in place of placeholder

Open ooade opened this issue 6 years ago • 3 comments

Deprecate placeholder. Maybe? And use src={[imagePlaceholder,image]}.

ooade avatar Jul 11 '18 16:07 ooade

hello, we want to deprecate placeholder to use array of imagePlaceholder and image right? Thanks in advance.

Oluwasetemi avatar Oct 11 '18 10:10 Oluwasetemi

  • Deprecating placeholder will still allow the use of placeholder but will warn if used, to be deprecated in the next major version.
  • Src attribute will take an array of images or a string. The things to check for:
    • One will have to check for the typeof src
    • If src is a string, we just assume the user doesn't want to pass a placeholder, and just renders the image although if it's a cloudinary image, we'll still lazy load it.
    • If an array is passed to src, and the length is not 2, warn about not passing the right set of props.
    • We'll still render the same placeholder for different srcset(s) as the placeholder is blurry. I might be the one to implement this tho.

RFC

Normally, I would have said we should distinguish placeholders and the real images with a comma(,) as done is srcset. Just thought about the way it might look like if we decided to leave it that way. But, if done with arrays, it can easily extend to the next line with prettier.

ooade avatar Oct 11 '18 17:10 ooade

Here now!!!

Oluwasetemi avatar Nov 01 '18 02:11 Oluwasetemi