Skip to content

Fix issue #61: Ensure course images are square to avoid scaling issues#62

Merged
A1L13N merged 6 commits into
alphaonelabs:mainfrom
Satyamkumarnavneet:fix-course-images
Feb 9, 2025
Merged

Fix issue #61: Ensure course images are square to avoid scaling issues#62
A1L13N merged 6 commits into
alphaonelabs:mainfrom
Satyamkumarnavneet:fix-course-images

Conversation

@Satyamkumarnavneet
Copy link
Copy Markdown
Contributor

This pull request resolves issue #61 by ensuring that course images are displayed as squares, preventing any scaling issues. The following changes have been made:

  1. HTML Template Update:

    • Modified the search.html template to ensure course images are displayed with a square aspect ratio.
    • Added a new div style to maintain this square aspect ratio, improving the visual consistency of the images.
  2. In create_test_data.py:

    • Added external_url="https://example.com/default-material" when creating CourseMaterial instances. This ensures that the external_url field, which likely has a NOT NULL constraint, is always populated with a valid URL, preventing potential database errors during test data creation.
  3. In models.py:

    • Included "assignment" as a valid choice for the material_type field in the CourseMaterial model. This addition expands the flexibility of course materials, allowing the creation and management of more diverse types of content.

Copy link
Copy Markdown
Contributor

@A1L13N A1L13N left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great can you please also apply this to the homepage and the detail.HTML page as well as the create a new course page and the image upload currently crops to the rectangle please make the crop function be a square

Comment thread web/management/commands/create_test_data.py Outdated
@Satyamkumarnavneet
Copy link
Copy Markdown
Contributor Author

Updated fix the issue and make these changes

  1. Model Update (models.py):

    • Updated the help_text for the image field to reflect the new 300x300px square aspect ratio.
    • Adjusted the image processing logic to crop and resize images into a square format (300x300px).
  2. Template Update (search.html, index.html, detail.html):

    • Added a wrapper div with specific styles (width: 300px; height: 300px; overflow: hidden) to enforce a consistent square aspect ratio for course images.
    • Updated the image rendering to use object-fit: cover, ensuring the images fill the square area without distortion.
  3. Code Refinements:

    • Refined the layout and styling to ensure a consistent and polished visual presentation of course images across various pages.

These changes not only address the original issue of image scaling but also improve the overall appearance of course frames. While the main goal was to ensure that images are uploaded as squares in models.py, I also fixed the course frames' display, which now looks much better than before.

@Satyamkumarnavneet
Copy link
Copy Markdown
Contributor Author

Looks great can you please also apply this to the homepage and the detail.HTML page as well as the create a new course page and the image upload currently crops to the rectangle please make the crop function be a square

Thanks for the feedback! Just to clarify, could you please elaborate a bit on what you mean by "create a new course page"? As we already have the "Courses" section in the navigation bar, I want to make sure I understand if you're referring to something specific that needs to be added or updated. Let me know, and I'll proceed with the changes!

Comment thread web/models.py Outdated
@A1L13N
Copy link
Copy Markdown
Contributor

A1L13N commented Feb 9, 2025

Looks great can you please also apply this to the homepage and the detail.HTML page as well as the create a new course page and the image upload currently crops to the rectangle please make the crop function be a square

Thanks for the feedback! Just to clarify, could you please elaborate a bit on what you mean by "create a new course page"? As we already have the "Courses" section in the navigation bar, I want to make sure I understand if you're referring to something specific that needs to be added or updated. Let me know, and I'll proceed with the changes!

When a user creates a new course, they upload an image, I'm not sure if we have an image preview there but I think we don't so I think this is complete. Can you please run the pre-commit so the files get formatted and pass the test? Then we can merge! Thank you!

Copy link
Copy Markdown
Contributor

@A1L13N A1L13N left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please run the pre-commit linting

@A1L13N A1L13N merged commit 981e3bf into alphaonelabs:main Feb 9, 2025
@A1L13N
Copy link
Copy Markdown
Contributor

A1L13N commented Feb 9, 2025

Congratulations on your first merged PR!

@Satyamkumarnavneet
Copy link
Copy Markdown
Contributor Author

Congratulations on your first merged PR!

Thank you! Sorry for the delay, I’ve been working on resolving the issue, but it’s still not fixed. It says 'flake8...................................................................Failed.

@Satyamkumarnavneet Satyamkumarnavneet deleted the fix-course-images branch February 10, 2025 09:02
Inshamhaque pushed a commit to Inshamhaque/education-website that referenced this pull request Mar 16, 2025
…-images

Fix issue alphaonelabs#61: Ensure course images are square to avoid scaling issues
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

make the images for courses square so we don't have scaling issues

2 participants