Skip to content

How to exactly use custom renderer? #115

Answered by igordanchenko
belfortf asked this question in Q&A
Discussion options

You must be logged in to vote

Hi there!

You can add custom photo attributes by simply adding them to your photo objects, just don't cast the photos array to Photo[].

const photos = unsplashPhotos.map((photo) => ({
    src: unsplashLink(photo.id, photo.width, photo.height),
    width: photo.width,
    height: photo.height,
    alt: photo.title, //I added this line
    category: photo.category, // photo category
    price: photo.price, // photo price
    srcSet: breakpoints.map((breakpoint) => {
        const height = Math.round((photo.height / photo.width) * breakpoint);
        return {
            src: unsplashLink(photo.id, breakpoint, height),
            width: breakpoint,
            height,
        };
    }),
}));

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@belfortf
Comment options

Answer selected by belfortf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants