Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Override img[width] and img[height] attributes #176

Closed
codingjoe opened this issue Jun 26, 2024 · 1 comment · Fixed by #177
Closed

Override img[width] and img[height] attributes #176

codingjoe opened this issue Jun 26, 2024 · 1 comment · Fixed by #177
Labels
bug Something isn't working

Comments

@codingjoe
Copy link
Owner

Hi @codingjoe,

The library offers extensive functionality and simplifies the transition from legacy <img> tags to the modern <picture> tags. While I appreciate the push towards using <picture>, there are numerous scenarios where explicitly setting image sizes is beneficial.

Currently, the <picture> tag inherits the original image size from the <img> tag, affecting the resulting container as well. So every image insertion will have the original image's size on website in some cases. Although reverting to the legacy implementation is an option, it undermines the benefits of upgrading from django-stdimage to django-pictures.

What do you think about adding an ability to set explicit image size from template tag?

Originally posted by @atnartur in #147 (comment)

@codingjoe codingjoe added the enhancement New feature or request label Jun 26, 2024
@codingjoe
Copy link
Owner Author

The attributes are rended in this line:

<img src="{{ field_file.url }}" alt="{{ alt }}" width="{{ field_file.width }}" height="{{ field_file.height }}"{% include 'pictures/attrs.html' with attrs=img_attrs %}>

When we move, the height and width attributed to the img_attrs dictionary as defaults, they can be overwritten via {% picture foo.bar img_height=600 img_height=800 %}

Go ahead @atnartur with your patch, thanks!

Best
Joe

@codingjoe codingjoe changed the title Hi @codingjoe, Override img[width] and img[height] attributes Jun 26, 2024
@codingjoe codingjoe added bug Something isn't working and removed enhancement New feature or request labels Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant