Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support gifs in ideal image plugin #4115

Open
semoal opened this issue Jan 28, 2021 · 4 comments
Open

Support gifs in ideal image plugin #4115

semoal opened this issue Jan 28, 2021 · 4 comments
Labels
feature This is not a bug or issue with Docusausus, per se. It is a feature request for the future.

Comments

@semoal
Copy link
Contributor

semoal commented Jan 28, 2021

🐛 Bug Report

Plugin itsel supports .gif (on webpack configuration) but this plugin doesn't work with gif https://github.com/endiliey/responsive-loader (i guess)

Have you read the Contributing Guidelines on issues?

Yes

To Reproduce

<Image
  img={require("../../static/img/real-code.gif")}
/>

Expected behavior

To work correctly.

Actual Behavior

./static/img/real-code.gif
Error: No mime type for file with extension gifsupported
 @ ./src/pages/index.tsx 1:9091-9132
 @ ./.docusaurus/registry.js
 @ ./node_modules/@docusaurus/core/lib/client/exports/ComponentCreator.js
 @ ./.docusaurus/routes.js
 @ ./node_modules/@docusaurus/core/lib/client/clientEntry.js
 @ multi ./node_modules/react-dev-utils/webpackHotDevClient.js ./node_modules/@docusaurus/core/lib/client/clientEntry.js

Your Environment

  • Docusaurus version used: alpha@70
@semoal semoal added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Jan 28, 2021
@slorber
Copy link
Collaborator

slorber commented Jan 28, 2021

hmmm that's right, I didn't expect this to work.

Temporarily we could remove it from the Webpack config.

It seems the latest sharp package can handle gifs: lovell/sharp#2012

But it requires a custom libvips install: https://sharp.pixelplumbing.com/install#custom-libvips

I'd rather document that we don't support gif resizes in that plugin, and let the user build his own plugin if he wants to

@slorber slorber mentioned this issue Jan 29, 2021
@alex-drocks
Copy link

alex-drocks commented Apr 21, 2021

It actually cannot use .gif images in general :(

I tried:

//docs/file.mdx
import Image from '@theme/IdealImage';
import LazyLoad from 'react-lazyload';
import additionSoustraction from "../../static/img/transactions/additions-soustractions.gif"
//...
<Image img={additionSoustraction}/>

<LazyLoad height={381}>
  <img src={additionSoustraction} alt={"Exemple d'addition et soustraction"}/>
</LazyLoad>

<img src="../../static/img/transactions/additions-soustractions.gif" alt="Exemple d'addition et soustraction"/>

<img src="./additions-soustractions.gif" alt="Exemple d'addition et soustraction"/>

None of these will show the .gif image.`
The problem seems to be at the loader level I don't know if it's webpack or internals.

Only those will work:

<img
  src="https://docs.finance-d.com/logiciel-tenue-de-livres-simplifiee/test-gif-image/additions-soustractions.gif"
  alt="Exemple d'addition et soustraction"
/>

// Only in production builds:
<LazyLoad height={381}>
  <img
    src="../../../img/transactions/additions-soustractions.gif" // the build path only accessible in production
    alt="Exemple d'addition et soustraction"
  />
</LazyLoad>

@Rocket-Fish
Copy link

Rocket-Fish commented May 8, 2021

In case anyone else is stuck on this issue. Workaround on 2.0.0-alpha.72 would be to just use markdown
![dodge gif](./dodge.gif) Im not sure why this works, maybe its skipping the rule ideal image chained into webpack somehow?

What doesn't work is the following:

import Image from '@theme/IdealImage';
<Image img={require('./dodge.gif')} />

I ran the build command and saw some extra logs:

Client bundle compiled with errors therefore further build is impossible.
./docs/uploads/dodge.gif
Module build failed (from ./node_modules/@endiliey/responsive-loader/lib/index.js):
Error: No mime type for file with extension gifsupported
    at Object.loader (/Users/[redacted-path]/[redacted-project-name]/node_modules/@endiliey/responsive-loader/lib/index.js:78:29)

I checked the ideal image plugin and its webpack config includes gif packages/docusaurus-plugin-ideal-image/src/index.ts

However If we go check @docusaurus/responsive-loader on npm itself it doesn't seem to say it support gifs?

If we go further up the fork tree.

@docusaurus/responsive-loader is based off of slorber/responsive-loader

which is in turn fork of rdilweb/responsive-loader

which is then in turn a fork of endiliey/responsive-loader

if one goes to any of those 3 repositories above and look at index.js line 4; none of them contains the mime type gif.
Am I missing something? or does it look like gif support is missing/removed in this loader entirely?

I checked blame for the repository git blame for the file

It seems like someone disabled gif mime type 5 years ago?
Screen Shot 2021-05-08 at 4 08 59 PM

@slorber
Copy link
Collaborator

slorber commented May 10, 2021

Going to remove the .gif extension from the ideal image loader regexp in #4708 as for me it's a mistake.

Please don't consider ideal image support gif: if you want to add gif support, you will need to add your own webpack loader for now.

I consider this issue a feature request, and we'll eventually see how to add gif support if it's not too complicated

@Josh-Cena Josh-Cena changed the title v2: plugin-ideal-image doesn't work with .gif format Support gifs in ideal image plugin Oct 30, 2021
@Josh-Cena Josh-Cena added feature This is not a bug or issue with Docusausus, per se. It is a feature request for the future. and removed bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Oct 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature This is not a bug or issue with Docusausus, per se. It is a feature request for the future.
Projects
None yet
Development

No branches or pull requests

5 participants