Skip to content

Commit

Permalink
Fix GIFs not loading in production (#72)
Browse files Browse the repository at this point in the history
* Implement manual checking for gifs

* Document a new function

* Update yarn.lock

* Upgrade stylelint-config-sass-guidelines

* Add postcss as a dev dependency

* Satisfy reqs for latest sass-guidelines
  • Loading branch information
raymosun authored Oct 2, 2023
1 parent 01b7856 commit 600c7c1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/components/leaderboard/LeaderboardRow/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { isSrcAGif } from '@/lib/utils';
import Image from 'next/image';
import Link from 'next/link';
import type { RefObject } from 'react';
Expand Down Expand Up @@ -37,6 +38,7 @@ const LeaderboardRow = ({
quality={10}
alt={`Profile picture for ${name}`}
className={styles.profilePicture}
unoptimized={isSrcAGif(image)}
/>
<div className={styles.nameRank}>
<span className={styles.name}>
Expand Down
7 changes: 7 additions & 0 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,10 @@ export const getUserRank = (user: PublicProfile): string => {

return ranks[index] ?? '';
};

/**
* Checks whether an image source is a gif
* @param src - source of the image
* @returns whether or not the source is a gif
*/
export const isSrcAGif = (src: string): boolean => /\.gif($|&)/.test(src);

1 comment on commit 600c7c1

@vercel
Copy link

@vercel vercel bot commented on 600c7c1 Oct 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.