-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Background image for Collection and Category #1882
Background image for Collection and Category #1882
Conversation
Waiting for images for populatedb |
44e6d5d
to
9b7a1e5
Compare
Codecov Report
@@ Coverage Diff @@
## master #1882 +/- ##
=========================================
Coverage ? 84.55%
=========================================
Files ? 160
Lines ? 6871
Branches ? 704
=========================================
Hits ? 5810
Misses ? 870
Partials ? 191
Continue to review full report at Codecov.
|
saleor/core/utils/random_data.py
Outdated
return product_list_images_dir | ||
|
||
|
||
def get_product_list_image(image_dir, image_name): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This name could be more general, as it's functionality is just to open a file.
saleor/product/models.py
Outdated
@@ -29,6 +29,8 @@ class Category(MPTTModel): | |||
parent = models.ForeignKey( | |||
'self', null=True, blank=True, related_name='children', | |||
on_delete=models.CASCADE) | |||
background_image = VersatileImageField( | |||
upload_to='category_backgrounds', blank=True, null=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we rather use hyphen here? Similar problem was mentioned in #1553. Same below.
@@ -98,6 +98,12 @@ <h3 class="d-md-none float-left filters-toggle"> | |||
</div> | |||
{% endblock %} | |||
|
|||
{% block topcontent %} | |||
{% if object.background_image %} | |||
<div class="row" id="product-list-image" style="background-image: url('{{ object.background_image.url }}')"></div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about making sure that the image is not too big (mainly dimensions)?
For example, if we have a staff member that would upload unoptimized pictures, like a picture taken from a mobile camera.
Currently .container
has a max-width
of 1140px
, maybe we could do something to prevent the page from being too data heavy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As an enhancement, background_image should be generated in various sizes, same as product images, so I'd not bother for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay then 👍
4d27eee
to
56024b0
Compare
…rl with inproper slug
56024b0
to
822cb4b
Compare
In this pull request I've added ability to upload background image for Categories and Collections.
Moreover, adequate images are added to Categories and Collections created by running
populatedb
command.Collections are more organized, created from schema, without randomly generated names.
Mobile
Desktop
TODO:
Pull Request Checklist
(Please keep this section. It will make maintainer's life easier.)
pycodestyle
,pydocstyle
,pylint
.eslint
.