Skip to main content

An add-on for Plone

Project description

https://github.com/codesyntax/cs.srcset/actions/workflows/plone-package.yml/badge.svg Latest Version Egg Status https://img.shields.io/pypi/pyversions/cs.srcset.svg?style=plastic:alt:Supported-PythonVersions License

cs.srcset

Backport of the srcset method added to the @@images view in plone.namedfile 7.1.0 to be able to use it in older Plone versions

Features

It adds a view called @@images-srcset that has a single method called srcset to be able to create an img tag with the srcset and sizes attributes to render responsive images.

Read more about responsive images and its use in the MDN documentation

Documentation

You should use this view like this

<img tal:define="images context/@@images-srcset;"
 tal:replace="structure python:images.srcset(
                             fieldname='image',
                             scale_in_src='huge',
                             sizes='(min-width: 570px) 550px,90vw',
                             css_class='mini w-100 h-100 responsive-3-2',
                             alt=context.Title(),
                             title=context.Title(),
                             loading='lazy')"
/>

The meaning of each parameter is the following:

  • fieldname: name of the field where the image is stored

  • scale_in_src: name of the scale that will be used to render the src attribute

  • sizes: the value of the sizes attribute in the output tag

  • css_class: CSS classes added to the img tag

  • additional attributes: any aditional attribute that will be rendered in the img tag, useful to add the title, alt, loading, fetchpriority, id, and other attributes.

Installation

Install cs.srcset by adding it to your buildout:

[buildout]

...

eggs =
    cs.srcset

and then running bin/buildout

NOTE: You do not need to install the product in the Plone add-ons controlpanel, there is nothing to be installed.

Contribute

Support

If you are having issues, please let us know.

License

The project is licensed under the GPLv2.

Contributors

Changelog

1.0 (2025-09-24)

  • Initial release. [codesyntax]

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

cs_srcset-1.0.tar.gz (22.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cs.srcset-1.0-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

Details for the file cs_srcset-1.0.tar.gz.

File metadata

  • Download URL: cs_srcset-1.0.tar.gz
  • Upload date:
  • Size: 22.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.2

File hashes

Hashes for cs_srcset-1.0.tar.gz
Algorithm Hash digest
SHA256 cc1d8c002dfca00e9326fb82ad82c7bfdf6a66facb2620c99d12607dcbf83a54
MD5 06a39fa21a17a65da24a577eb1e0bd6e
BLAKE2b-256 d9a439e60ec4931e7dd5e072e3ec8262fd7b81bc196bb05a24ee28151f35f3ad

See more details on using hashes here.

File details

Details for the file cs.srcset-1.0-py3-none-any.whl.

File metadata

  • Download URL: cs.srcset-1.0-py3-none-any.whl
  • Upload date:
  • Size: 19.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.2

File hashes

Hashes for cs.srcset-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c963f4f1de40e075ece7914f112a4192b65c54060cf34c86cb0804169543f5ef
MD5 4bc01d25ce3d99766eccd71f4f20798b
BLAKE2b-256 ca8efd52e6237bf602df975c16c85b331ba151fe5c2b8fea8e6ed7ee3f8f3cad

See more details on using hashes here.

Supported by

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