electerious / basicLightbox

The lightest lightbox ever made.
https://basiclightbox.electerious.com
MIT License
557 stars 55 forks source link

Demo for srcset support #10

Open strarsis opened 6 years ago

strarsis commented 6 years ago

A demo for srcset support would be great!

electerious commented 6 years ago

You can use srcset like usual. Here's a quick demo:

import * as basicLightbox from 'basiclightbox'

const instance = basicLightbox.create(`
    <img src="assets/images/image.png" srcset="image.png 1x, image@2x.png 2x" width="800" height="600">
`)

instance.show()

I agree that an official demo would be nice! PR welcome.

strarsis commented 6 years ago

@electerious: And can this lightbox also re-use the srcset from an existing linked <img>?

electerious commented 6 years ago

Yes, basicLightbox can show whatever you pass to it. Here's a quick example (untested):

import * as basicLightbox from 'basiclightbox'

const img = document.querySelector('#img')
const html = img.outerHTML
const instance = basicLightbox.create(html)

instance.show()
strarsis commented 6 years ago

@electerious: A WordPress plugin would be great! I cannot find a plugin that offers srcset support (which WordPress already provides for the <img>s). This would be unique :)