-
Notifications
You must be signed in to change notification settings - Fork 30
homepage image endpoint + random image on home screen #1978
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
base: dev
Are you sure you want to change the base?
Conversation
| const { OK, NOT_FOUND } = require('../../util/constants').STATUS_CODES; | ||
| const { getRandomImageUrl } = require('../util/HomepageImages'); | ||
|
|
||
| router.get('/image', (req, res) => { |
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.
can we change this file to be image.js and the endpoint /homepage?
that way we can do /image/homepage, and later we can reuse this file for /image/projects
| @@ -0,0 +1,16 @@ | |||
| //sample images (all from openverse.org) for now!! | |||
| const imageUrls = [ | |||
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.
lets put this in the routes file, its not much codee
and can we change the description field to alt and return the entire object (url and alt) as the api response
| <img | ||
| className="w-full mx-auto transform md:w-4/5 rounded-xl" | ||
| src="https://raw.githubusercontent.com/thebeninator/Clark/refs/heads/add_comp_homepage/public/images/compressed2.jpg" | ||
| src={homeImageUrl} |
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.
we can use the .url field here, and add an alt tag using the api response
| async function loadHomeImage() { | ||
| const response = await getHomeImageUrl(); | ||
| const url = response.responseData; | ||
| if (!response.error && url) { | ||
| setHomeImageUrl(url.trim()); | ||
| } else { //old image if error | ||
| setHomeImageUrl('https://raw.githubusercontent.com/thebeninator/Clark/refs/heads/add_comp_homepage/public/images/compressed2.jpg'); | ||
| } | ||
| } |
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.
how about something like
async function loadHomeImage() {
const DEFAULT_IMAGE = 'https://raw.githubusercontent.com/thebeninator/Clark/refs/heads/add_comp_homepage/public/images/compressed2.jpg';
const response = await getHomeImageUrl();
let url = DEFAULT_IMAGE;
let alt = 'sce club image';
if (!response.error) {
url = response.responseData.url;
alt = response.responseData.alt;
}
setHomeImageUrl(url);
setAltText(alt); // need to add new alt field
}
for issue #1952
has random images i found online for now