
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
ib-image-optimizer
Advanced tools
A React component for optimizing images with loading states and aspect ratio control
A React component for optimizing images with loading states and error handling.
npm install ib-image-optimizer
import { ImageOptimizer } from "ib-image-optimizer/use-react";
function App() {
return (
<ImageOptimizer
src="https://example.com/image.jpg"
fallbackSrc="https://example.com/fallback.jpg"
aspectRatio="square"
onLoad={() => console.log("Image loaded")}
onError={(error) => console.error("Image failed to load:", error)}
/>
);
}
The component is designed to work seamlessly with Next.js server components:
// app/page.tsx
import { ImageOptimizer } from "ib-image-optimizer/use-react";
export default function Page() {
return (
<ImageOptimizer
src="/images/hero.jpg"
fallbackSrc="/images/fallback.jpg"
aspectRatio="landscape"
/>
);
}
Prop | Type | Description |
---|---|---|
src | string | The source URL of the image |
fallbackSrc | string | Fallback image URL to display if the main image fails to load |
aspectRatio | "auto" | "square" | "portrait" | "landscape" | Controls the aspect ratio of the image container |
onLoad | () => void | Callback fired when the image loads successfully |
onError | (error: Error | ErrorEvent) => void | Callback fired when the image fails to load |
className | string | Additional CSS classes to apply to the container |
style | React.CSSProperties | Inline styles to apply to the container |
showSkeleton | boolean | Whether to show a skeleton loading state (default: true) |
MIT
Contributions are welcome! Please feel free to submit a Pull Request.
FAQs
A React component for optimizing images with loading states and aspect ratio control
The npm package ib-image-optimizer receives a total of 6 weekly downloads. As such, ib-image-optimizer popularity was classified as not popular.
We found that ib-image-optimizer demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.