-
Notifications
You must be signed in to change notification settings - Fork 87
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
Add fallback image for the course card images #324
base: master
Are you sure you want to change the base?
Conversation
const { bannerImgSrc } = reduxHooks.useCardCourseData(cardId); | ||
const { homeUrl } = reduxHooks.useCardCourseRunData(cardId); | ||
const { isVerified } = reduxHooks.useCardEnrollmentData(cardId); | ||
const { disableCourseTitle } = useActionDisabledState(cardId); | ||
const handleImageClicked = reduxHooks.useTrackCourseEvent(courseImageClicked, cardId, homeUrl); | ||
const wrapperClassName = `pgn__card-wrapper-image-cap overflow-visible ${orientation}`; | ||
const fallbackImageSrc = `${getConfig().LMS_BASE_URL}/theming/asset/images/no_course_image.png`; |
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.
Is the no_course_image.png
asset included by default as part of edx-platform
? I was trying to check now and I can't find any assets in the master
branch with this name, but maybe I am missing it.
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.
Ah, re-reading your description now, I believe you're saying that the Open edX operator must provide an asset with this name for this feature to work?
I'm a little nervous that this feature would be a bit hard to discover. I think it would be better for operators if there were some standard theme-agnostic placeholder images available in edx-platform that we're referencing.
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.
There is precedent for hosting a filler image in the MFE itself in case of absence:
frontend-app-learner-dashboard/src/containers/CoursesPanel/NoCoursesView/index.jsx
Line 7 in d3779ad
import emptyCourseSVG from 'assets/empty-course.svg';
I'm not saying I prefer this, architecturally speaking, but it would be a more immediate fix than adding placeholder images to edx-platform.
Also, I don't think hard-cording a reference to an image that needs to be provided as part of a comprehensive theme (something that's likely going away in the future), is the right thing to do here. If we're hard-coding something, it needs to be part of the vanilla edx-platform theme.
Hi @mphilbrick211 -- Is this something that would need product eyes from Axim? |
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.
Blocking momentarily while it is determined if we need further feedback from Axim product folks.
Thanks for flagging, @justinhynes - will check with Jenna now. |
This is a good fix, thanks! Will this default image work for any instance? I noted you mentioned it works with the indigo theme, will it work for anyone using tutor? This has product approval. |
Yes, it works with indigo theme because in indigo theme, |
@hinakhadim What is the behavior if the asset doesn't exist in an alternate theme? Does it fallback to the current behavior (showing a broken image?) or something worse (hopefully not an error?) |
Yes, it fallback to the current behavior (showing a broken image). I've tested with image not existing then it didn't throw error and showed the current behavior. |
const { bannerImgSrc } = reduxHooks.useCardCourseData(cardId); | ||
const { homeUrl } = reduxHooks.useCardCourseRunData(cardId); | ||
const { isVerified } = reduxHooks.useCardEnrollmentData(cardId); | ||
const { disableCourseTitle } = useActionDisabledState(cardId); | ||
const handleImageClicked = reduxHooks.useTrackCourseEvent(courseImageClicked, cardId, homeUrl); | ||
const wrapperClassName = `pgn__card-wrapper-image-cap overflow-visible ${orientation}`; | ||
const fallbackImageSrc = `${getConfig().LMS_BASE_URL}/theming/asset/images/no_course_image.png`; |
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.
There is precedent for hosting a filler image in the MFE itself in case of absence:
frontend-app-learner-dashboard/src/containers/CoursesPanel/NoCoursesView/index.jsx
Line 7 in d3779ad
import emptyCourseSVG from 'assets/empty-course.svg';
I'm not saying I prefer this, architecturally speaking, but it would be a more immediate fix than adding placeholder images to edx-platform.
Also, I don't think hard-cording a reference to an image that needs to be provided as part of a comprehensive theme (something that's likely going away in the future), is the right thing to do here. If we're hard-coding something, it needs to be part of the vanilla edx-platform theme.
@arbrandes agree to your point. import emptyCourseSVG from 'assets/empty-course.svg'; This image is looking weird to fix the broken image. If you can share other alternative, then i'll really appreciate it. |
Apologies, I didn't mean to say we should use that image. We'll need to create a new one that works for this use case. |
Sure. Can you please mention the team who will take care of this? |
Good question. I guess I was expecting you'd be able to submit the one in Indigo here, but of course, that is presuming a lot. :) If that's not the case, then it's just something we'll have to add to the community backlog for somebody to pick up (including, possibly, Axim itself, but I can't promise we'll have the capacity soon). |
We have included this image in indigo theme and add its link here in What are your thoughts on this regarding architecture considering future updates in LMS and MFE and user independence? (As studio/CMS also moved to MFE) |
Good point. This means we should make the image overridable via brand-openedx, or, as mentioned earlier, we make the image available as part of the default Open edX theme in edx-platform, so that users don't have to have indigo installed for this to work. I prefer the first option, as it decouples the UI from the backend a little bit more. But it would be best if the image were provided as an SVG, as opposed to a PNG, if at all possible. |
Awesome. Including image in brand-openedx seems the best option because users can fork brand-openedx for image replacement instead of learner-dashboard mfe. I am able to include Module not found: Can't resolve 'react' in '/openedx/brand-openedx/paragon/images'
brand-openedx/paragon/images/no_course_image.svg |
@hinakhadim unless I'm misunderstanding how |
@jsnwesson I added that image in cloned brand-openedx (one in png format and one in svg format). I then use that brand-openedx using import FallbackImageSrc from '@edx/brand/paragon/images/no_course_image.png';
// use it like
<img
className="pgn__card-image-cap show"
src={!hasImageError ? bannerImgSrc : FallbackImageSrc}
alt={formatMessage(messages.bannerAlt)}
onError={() => {
if (!hasImageError) { setHasImageError(true); }
}}
/> The above works fine and loaded the image. But when I try to use import FallbackImageSrc from '@edx/brand/paragon/images/no_course_image.svg'; OR
import * as FallbackImageSrc from '@edx/brand/paragon/images/no_course_image.svg'; |
When there is no image for course, then the screen shows alt text with broken image icon. This PR fixes it by adding an error image url. The Error image needs to be added in
edx-platform
with nameno_course_image.png
. This works perfectly with eventutor-indigo
or any theme you want to set usingtutor
.Before:
After:
If the image exists in theme:
If the image with name
no_course_image.png
won't exist, then it will show the alt text with broken image icon.Impact: