Skip to content

Conversation

@jctimbol
Copy link

for issue #1952
has random images i found online for now

const { OK, NOT_FOUND } = require('../../util/constants').STATUS_CODES;
const { getRandomImageUrl } = require('../util/HomepageImages');

router.get('/image', (req, res) => {
Copy link
Collaborator

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 = [
Copy link
Collaborator

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}
Copy link
Collaborator

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

Comment on lines +26 to +34
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');
}
}
Copy link
Collaborator

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
  }

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.

2 participants