Giter Club home page Giter Club logo

markupsrcset's People

Contributors

rolandtoth avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

markupsrcset's Issues

Call to undefined function ProcessWire\stringToArray()

I just installed you updated module, but unfortunately it does not work, because I get a fatal error:
<b>Fatal error</b>: Uncaught Error: Call to undefined function ProcessWire\stringToArray() in .../site/modules/MarkupSrcSet/MarkupSrcSet.module:123

Btw, i really welcome your api changes!

Request: keep order of srcsetUrls

It would be nice if there would be a way get the $img->srcsetUrls array in the same order as defined in the $img->srcset('900,*2,/2') call.

Another suggestion would be to use 'smallest' and 'largest' instead of 'first'/'last'.
I forked your repo and implemented my suggestions here:
phlppschrr@71d30bc

Background to this request is, I want to use lazysizes like described here:
https://github.com/aFarkas/lazysizes#modern-transparent-srcset-pattern where it is recommended that the first image candidate in data-srcset matches the src fallback image.

With these changes I could do it like this:

<img
    data-srcset="<?= $img->srcset('900x0,*2,/2') ?>"
    src="<?= $img->srcsetUrls[0] ?>"
    srcset="<?= $config->srcsetFallbackDataUri ?>"
    alt="<?= $img->description ?>"
    data-sizes="auto"
    class="lazyload" />

width descriptor should specify the width of the image

Hi,

i wanted to use the MarkupSrcSet module but noticed it's output differs from the specification of srcset and sizes.

The w descriptor should specify the width of the image and not a breakpoint. See https://ericportis.com/posts/2014/srcset-sizes/

srcset takes a comma-separated list of URLs for the available versions of the image; each image’s width is specified using the w descriptor. So if you “Save for Web…” at 1024 × 768, mark that source up in srcset as 1024w.

With the implementation right now, the browsers will assume the wrong image dimensions.

I think, the breakpoint setting could be left out and an option for the sizes attribute for each preset should be introduced.

this could look like this:

{
    "hero": {
        "srcset": [
              [360, 270], [640, null], [1080, null], [1920, null]
       ],
        "sizes": "(min-width: 36em) 33.3vw, 100vw",
    }
}

So the output would look like this:

<img 
    src="image.360x0.jpg" 
    srcset="image.360x0.jpg 360w, image.640x0.jpg 640w, image.1080x0.jpg 1080w, image.1920x0.jpg 1920w" 
    sizes="(min-width: 36em) 33.3vw, 100vw" 
    alt="">
```

What do you think?

example output

Hello! would it be possible to add example html outputs to your readme?

PHP 8.0 & 8.1 Warnings

Moving to PHP 8.x I get a ton of warnings like this:

Warning: ProcessWire\MarkupSrcSet::ProcessWire\{closure}(): Argument #1 ($item) must be passed by reference, value given in /Users/bla/Sites/bla/site/modules/MarkupSrcSet/MarkupSrcSet.module on line 176

Removing the & from L. 174
$currentSize = array_map(function (&$item) use ($multiplier) {
to
$currentSize = array_map(function ($item) use ($multiplier) {

seems to fix it, but I'm not really sure if what I'm doing here (changing from reference to value), has unforseen consequences. However the resulting HTML is identical.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.