Skip to content

[BUG] djangocms_picture output picture size as float, triggers warning in chrome #117

@TLuesebrinck

Description

@TLuesebrinck

In the 'srcset' and 'sizes' attribute of the img tag can contain float numbers.

This {{ picture_size.size.0}}w output the pixel size as 1366.0w which triggers this warning in chrome:

Failed parsing 'srcset' attribute value since its 'w' descriptor is invalid.

I solved this by using a float format filter to remove the decimal point:

{{ picture_size.size.0 | floatformat:"0" }}w

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions