Skip to main content

Django CMS plugin implementing html5 responsive images

Project description

djangocms-responsive-image
==========================

This package provides a plugin for Django CMS 3 similar to
cmsplugin\_filer\_image, but in addition can deliver multiple sizes as a html5
srcset attribute for the img tag.

configuration
-------------

How the srcset is built is determined by the style choices attribute.
You can configure them via the `DJANGOCMS_RESPONSIVE_IMAGE_IMAGE_STYLE_CHOICES`
setting:

DJANGOCMS_RESPONSIVE_IMAGE_IMAGE_STYLE_CHOICES = {
'fullwidth': {
'name': _('full width'),
'srcset': ((960, 0), (640, 0), ),
'sizes': '(max-width: 800px) 640px',
'default_size': (960, 0)
}
}

`srcset` ist a tuple of (width, height) tuples which will be used to create
the `srcset` img attribute and also to render the thumbnails with
`easy_thumbnails`.
`sizes` is the value of the `sizes` img attribute, refer to your favorite html5
documentation for information on how to use it. You can also omit it if
unnecessary.
`default_size` will be used for the `src` attribute and the corresponding thumbnail as a fallback for browsers which
don't support `srcset`.

By default, the srcset includes high-resolution (2x) images if the source image is large enough. You can disable
this behaviour by setting `DJANGOCMS_RESPONSIVE_IMAGE_ADD_2X = False`. If you are using custom templates older than
v0.1.1, you might update them to support 2x (see `templates/djangocms_responsive_image/default.html` for an example).

changelog
---------
0.1.1 added support for high-res images; bugfix
0.1.0 added description field and alt getter with fallback to the default\_alt\_text of the image
0.0.11 added fallback src attribute to default template

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

djangocms-responsive-image-0.1.1.tar.gz (5.4 kB view details)

Uploaded Source

File details

Details for the file djangocms-responsive-image-0.1.1.tar.gz.

File metadata

File hashes

Hashes for djangocms-responsive-image-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3b29474b2a8f00c8ff6808e721286792a4f99ca81e7dfd1c493a099986dc748e
MD5 128cf56fb7777c98d55fc9f943090a67
BLAKE2b-256 3e4c9bd93ef7ef221ff0083476f7e38a26a1710c3800ebe0bc802e91d4d568cd

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page