Giter Club home page Giter Club logo

picture's Introduction

Сниппет для формирования разных вариантов изображения под разные разрешения экрана и их вывода с использованием тега <picture>

Пример использования для сетки Bootstrap 4:

[[picture? &source=`assets/images/image.jpg` &phpthumboptions=`zc=1,f=jpg` &data=`[
	{
		"media": ">1200",
		"width": 1200,
		"height": 600,
		"alt": "test",
		"fallback": true
	}, {
		"media": ">992",
		"width": 1000
	}, {
		"media": ">768",
		"width": 800
	}, {
		"media": ">577",
		"width": 600
	}, {
		"media": "<577",
		"width": 400
	}
]`]]

На выходе получится это:

<picture>
	<source srcset="assets/cache/images/img-xl-1200x600-4fd.jpg 1x, assets/cache/images/img-xl-2400x1200-26a.jpg 2x" media="(min-width: 1200px)">
	<source srcset="assets/cache/images/img-xl-1000x500-f54.jpg 1x, assets/cache/images/img-xl-2000x1000-b7b.jpg 2x" media="(min-width: 992px)">
	<source srcset="assets/cache/images/img-xl-800x400-e37.jpg 1x, assets/cache/images/img-xl-1600x800-581.jpg 2x" media="(min-width: 768px)">
	<source srcset="assets/cache/images/img-xl-600x300-f1e.jpg 1x, assets/cache/images/img-xl-1200x600-4fd.jpg 2x" media="(min-width: 577px)">
	<source srcset="assets/cache/images/img-xl-400x200-963.jpg 1x, assets/cache/images/img-xl-800x400-eef.jpg 2x" media="(max-width: 576px)">
	<img src="assets/cache/images/img-xl-1200x600-4fd.jpg" srcset="assets/cache/images/img-xl-1200x600-4fd.jpg 1x, assets/cache/images/img-xl-2400x1200-26a.jpg 2x" alt="test" class="img-fluid">
</picture>

picture's People

Contributors

mnoskov avatar

Stargazers

Marc avatar Mikhail Sazanov avatar

Watchers

Marc avatar James Cloos avatar  avatar

Forkers

ditso

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.