NextImage encountering issues in Internet Explorer 11

In my TypeScript setup, here is a snippet from my package.json file:

"dependencies": {
"@tailwindcss/typography": "^0.4.1",
"@webcomponents/shadydom": "^1.7.4",
"cookie": "^0.4.1",
"js-cookie": "3.0.0-rc.4",
"next": "11.1.2",
"next-seo": "^4.7.1",
"next-themes": "^0.0.14",
"postcss-custom-properties": "^12.0.0",
"postcss-flexbugs-fixes": "^5.0.2",
"postcss-import": "^14.0.2",
"postcss-nesting": "^8.0.1",
"react": "17.0.2",
"react-app-polyfill": "^2.0.0",
"react-dom": "17.0.2",
"react-markdown": "^6.0.2" }

While next/image works smoothly in Chrome and Firefox, it fails to display in IE 11. The rendering output in IE 11 looks like this:

<div style="margin: 0px; overflow: hidden; display: inline-block; position: relative;
 max-width: 100%; box-sizing: border-box;">
       <div style="display: block; max-width: 100%; box-sizing: border-box;">
            <img aria-hidden="true" style="margin: 0px; padding: 0px; border: currentColor; border-image: none; display: block; max-width: 100%;" alt="" 
src="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAwIiBoZWlnaHQ9IjQwIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZlcnNpb249IjEuMSIvPg==">
      </div>
      <img style="margin: auto; padding: 0px; border: currentColor; border-image: none; left: 0px; top: 0px; width: 0px; height: 0px; right: 0px; bottom: 0px; display: block; position: absolute; min-height: 100%; max-height: 100%; min-width: 100%; max-width: 100%; box-sizing: border-box;" alt="" 
src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-nimg="intrinsic" decoding="async">
      <noscript>&lt;img alt="" srcSet="http://89.99.249.122:37/uploads/realtec_type_white_7e5b583ded.png 1x, http://89.99.249.122:37/uploads/realtec_type_white_7e5b583ded.png 2x" src="http://89.99.249.122:37/uploads/realtec_type_white_7e5b583ded.png" decoding="async" data-nimg="intrinsic" style="position:absolute;top:0;left:0;bottom:0;right:0;box-sizing:border-box;padding:0;border:none;margin:auto;display:block;width:0;height:0;min-width:100%;max-width:100%;min-height:100%;max-height:100%" loading="lazy"/&gt;</noscript>
</div>

Here's the relevant piece of code:

import { getMyMedia } from "@utils/medias"
import NextImage from "next/image"


const Image = ({img,...props})=>{
  const media = img

  const loader = ({ src }) => {
    return getMyMedia(src)
  }

    // The image has a fixed width and height
    if (props.width && props.height) {
      return (
        <NextImage loader={loader} src={media.url} alt={media.alternativeText || ""} {...props}  />
      )
    }

      // The image is responsive
  return (
    <NextImage
      loader={loader}
      layout="responsive"
      width={media.width}
      height={media.height}
      objectFit="contain"
      src={media.url}
      alt={media.alternativeText || ""}
    />
  )

}

export default Image

I encountered an error in IE 11 DevTools, which looks like this:

SCRIPT5022: Should not already be working.

Any suggestions on how to fix this?

Answer №1

Utilize the next-images library for comprehensive format support. Simply add its configuration to your next.config.js file.

// next.config.js
const withImages = require('next-images')
module.exports = withImages() 

Link to Library

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Encountering an issue with NgRx store where the property 'products' is not recognized on the type 'ActionCreatorProps<{ payload: Product[]; }>' while attempting to build a reducer

Currently, I am delving into the @ngRx/store package within my Angular 14 App. My primary goal is to establish a basic store capable of containing a simple object Array. Here is an excerpt from my action file: import { Product } from 'src/app/data-mod ...

Transforming a detailed JSON structure into a more simplified format with Angular 2

As a newcomer to Angular 2, I find myself encountering a hurdle in filtering unnecessary data from a JSON object that is retrieved from a REST API. Below is an example of the JSON data I am working with: { "refDataId":{ "rdk":1, "refDataTy ...

Issue: Encounter of "Uncaught (in promise) TypeError" while implementing RiveScript chatbot in Angular

I've been working on integrating a chatbot based on RiveScript into Angular. The chatbot is functioning well - I always see the correct response in the console. Displaying the user's input is also working seamlessly. However, I'm encounterin ...

React/Typescript - Managing various event types within a unified onChange function

In my current project, I am working with a form that includes various types of input fields using the mui library. My goal is to gather the values from these diverse input components and store them in a single state within a Grandparent component. While I ...

Checkbox selection limitation feature not functioning correctly

Having trouble with my checkbox question function - I want to limit the number of checkboxes that can be checked to 3, but it's still allowing more than that. I suspect the issue lies with latestcheck.checked = false; This is my typescript function: ...

What is the process for incorporating a middleware into my profile route on NextJS-13? I want to restrict access to only authenticated users and prevent unauthorized users from accessing the route

Creating a secure getProfile page for my nextjs app is proving to be a challenge. I need to protect the API route, which can be accessed at http://localhost:3000/api/user/123456. Only the current employee logged in with employeeid 123456 should have access ...

Accessing the map in an Angular 6 service via Leaflet

Embedding a map into my Angular 6 app service has been a bit tricky. Currently, I'm passing it as an argument when calling an init function in the service and providing it via Subject from the component after fetching data from the store. However, som ...

Typescript for managing the Shopify admin API

Is there anyone who can confirm whether Shopify offers typescript definitions for their admin API? I'm specifically interested in finding types for Orders, Products, and Variants. I initially assumed that this package would have them, but it seems l ...

Type of Multiple TypeScript Variables

Within my React component props, I am receiving data of the same type but with different variables. Is there a way to define all the type variables in just one line? interface IcarouselProps { img1: string img2: string img3: string img4: string ...

The useEffect hook in Next.js does not trigger a re-render when the route changes

I'm currently experiencing an issue with a useEffect inside a component that is present in every component. I've implemented some authentication and redirection logic in this component, but I've noticed that when using Next.js links or the b ...

Errors may occur when utilizing TypeScript with the Context Provider API in React

I am in the process of developing a theme changer feature and I want to save the color chosen by the user in the context. However, when I try to pass data to the value prop of the Context.Provider, I encounter an error message TS2739: Type 'Readonly&l ...

Next.js is experiencing difficulty serving dynamic images in real-time

Currently, my project uses Next.js API for the backend and MongoDB for the database. I am faced with the challenge of serving user-uploaded images at runtime, since these files were not available during build time and are not recognized as static files tha ...

A guide to accessing parent attributes in Vue3 using typescript

Within my child component, I am facing an issue where I need to access the parent object but the commented lines are not functioning as expected. The structure of AccordionState is defined below: export type AccordionKeys = | "open" | "disa ...

Instructions on how to present a list of employee information according to the user's gender preference using a selection of three radio buttons

I have developed a view that displays a table of employees, using a json array to store their details in the component. Additionally, I have implemented 3 radio buttons: all, male, and female. My goal is to have the table show all employees when "all" is ...

Issue with Material UI: Unable to utilize import statement outside of a module due to Select dependency

Hello there! Here is my query: I am currently working on a project using NextJS + React with node. Everything seems to be running smoothly, except for one issue I encounter when reloading a page with a Select component from Material UI. The relevant code ...

Vercel - Deploying without the need to promote the project

How can I deploy my Nextjs app to production in a way that allows me to run E2E tests on a "pre-prod" version before promoting it to prod, similar to using a preview URL without public traffic being directed there? I am looking for a process where I can v ...

When the React Native Expo app is running, the TextInput form is covered by the keyboard

When I launch the app using expo and implement my DateFormInput component, the issue of Keyboard covering TextInput arises. Despite trying packages like "@pietile-native-kit/keyboard-aware-scrollview", "@types/react-native-keyboard-spacer", "react-native-k ...

How to access elements by their class name in Angular

Recently, I encountered a situation with this specific span element: <span *ngFor="let list of lists[0].question; let i = index" id="word{{ i }}" (click)="changestyle($event)" class="highlight"> {{ list}} < ...

How can you conceal the navigation and footer components on a 404 page using Next.js?

import Footer from "./Footer"; import Navigation from "./Navigation"; import { useRouter } from "next/router"; function CustomLayout({ children }) { const router = useRouter(); return ( <> {router.pathname ...

Steps to host a Next.js 13 application on an IIS Server 10

Setting up iisnode and rewriting paths. Successfully deploying a next.js app on iis 10. Various resources provide different explanations. Is it necessary to configure iisnode and rewrite rules? The web.config settings can vary significantly. After numer ...