You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Broken images should be detected and replaced with proper graphics #40050
platform: learnUI side of the client application that needs familiarity with React, Gatsby etc.scope: curriculumLessons, Challenges, Projects and other Curricular Content in curriculum directory.
A broken image graphic looks, to me, like the site is not working correctly. I'd prefer the default avatar.
Ideally the user should be informed their avatar is broken on the settings page, if we can do that in a sensible way. Maybe validate the image and warn if it does not return status 200?
Here is a first fix in the handleSubmit method in the About.js component. It is just about seing if the provided url for the profil image is valid. If the provided url is incorrect, the default image is set. Should we maybe show some message if the provided url is incorrect ?
@Ismailtlem, yes, I think we should display a massage in that case.
If the user sends a broken image, we do not need to alter the form values.
So there are two possibilities here:
the user is trying to submit a broken image.
We can have client validations and check if the link is working, etc, and display an error accordingly.
the image ink breaks after submission.
For the second, there is an image onError event that we could utilize and display the default image. Showing the flash message is not necessary.
Any better solution to find if the url provided is valid apart from sending a get request to it ? A cors problem might appear that might block the incoming request. I tried also to use fetch with the following code on the About.js component but it also come with some misbehaviors
If one wants to add a flash message that doesn't exist yet (like a flash message saying that an incorrect picture url was provided), he should add also its translations to spanish and chinese right ?
Would only checking the extension of the image in the url as well as checking the presence of the http prefix (or https) with a regular expression be sufficient to check the correctness of a URL @ahmadabdolsaheb ? (Not so sure about that ..)
I added a parameter in the state for handling an incorrect image and displaying the error message
for the second point you mentionned @ahmadabdolsaheb regarding that the image might break after submission. Shall we create some script that checks that the url provided is still valide every 3 days or so ?
for the second point you mentionned @ahmadabdolsaheb regarding that the image might break after submission. Shall we create some script that checks that the url provided is still valide every 3 days or so ?
Adding a script is not necessary. The user should be able to recognize that their image is not matching the submitted image.
platform: learnUI side of the client application that needs familiarity with React, Gatsby etc.scope: curriculumLessons, Challenges, Projects and other Curricular Content in curriculum directory.
Activity
ahmaxed commentedon Oct 21, 2020
@ojeytonwilliams, should we show the default avatar or a broken image graphic instead?
ojeytonwilliams commentedon Oct 21, 2020
A broken image graphic looks, to me, like the site is not working correctly. I'd prefer the default avatar.
Ideally the user should be informed their avatar is broken on the settings page, if we can do that in a sensible way. Maybe validate the image and warn if it does not return status 200?
RandellDawson commentedon Oct 21, 2020
Why don't we just host the image for the avatar, so there would never be a broken image to begin with?
ojeytonwilliams commentedon Oct 21, 2020
The avatar's fine. We just just need to be able to handle the case where someone provides a link that doesn't point to an image.
amel-selmane commentedon Dec 27, 2020
Hello :) Do we have news about this graphic issue ?
ahmaxed commentedon Dec 27, 2020
@amel-selmane, We should go ahead with detecting if the user provided image is broken and show the default avatar.
Ismailtlem commentedon Mar 25, 2021
Can you guys sign in locally ? After running the project locally, clicking on the sign in button directs to http://localhost:3000/signin which doesn't return anything
RandellDawson commentedon Mar 25, 2021
@Ismailtlem Did you seed the database before running
npm run develop?You can try running the following per our documentation?
or
Ismailtlem commentedon Mar 25, 2021
works thanks
Ismailtlem commentedon Apr 1, 2021
Here is a first fix in the handleSubmit method in the About.js component. It is just about seing if the provided url for the profil image is valid. If the provided url is incorrect, the default image is set. Should we maybe show some message if the provided url is incorrect ?
What do you guys think ?
ahmaxed commentedon Apr 4, 2021
@Ismailtlem, yes, I think we should display a massage in that case.
If the user sends a broken image, we do not need to alter the form values.
So there are two possibilities here:
the user is trying to submit a broken image.
We can have client validations and check if the link is working, etc, and display an error accordingly.
the image ink breaks after submission.
For the second, there is an image onError event that we could utilize and display the default image. Showing the flash message is not necessary.
Ismailtlem commentedon Apr 15, 2021
Hi,
ShaunSHamilton commentedon Apr 15, 2021
@Ismailtlem
You need to dispatch an action (
createFlashMessage), which takes an object describing thetypeand themessage. Themessageshould be one of: https://github.com/freeCodeCamp/freeCodeCamp/blob/main/client/i18n/locales/english/translations.json#L410If it is new, then you add the English to all files, and they will be translated on Crowdin.
Now that you know what we call it (the action), it is easiest just to look how it has been used in other places in the client.
Hope this helps
Ismailtlem commentedon Apr 16, 2021
Would only checking the extension of the image in the url as well as checking the presence of the http prefix (or https) with a regular expression be sufficient to check the correctness of a URL @ahmadabdolsaheb ? (Not so sure about that ..)
ahmaxed commentedon Apr 17, 2021
Here are the suggestions from chat:
If there's any error, CORS or otherwise, we could consider the image invalid and display flash error.
Here are some resources from image verification:
https://stackoverflow.com/questions/9714525/javascript-image-url-verify
https://stackoverflow.com/questions/8124866/how-does-one-use-the-onerror-attribute-of-an-img-element
Please let us know if you would need more help with arriving at viable solution.
Ismailtlem commentedon Apr 26, 2021
Hi, I made a first trial in this PR #41927
Any feedbacks or improvements are very welcome
ahmaxed commentedon May 3, 2021
Thanks for working on this feature.
Adding a script is not necessary. The user should be able to recognize that their image is not matching the submitted image.
ahmaxed commentedon May 24, 2021
We would just need another pr to target the onError event of the profile images on the navigation and on the profile page and show the default image.
Ismailtlem commentedon May 30, 2021
Hi
ahmaxed commentedon Jun 1, 2021
Yes, if the image link breaks after submission. That is the root of the screenshot on the issue description.