在灯箱中镀铬非常小的图像

问题描述 投票:0回答:0

有时我打开灯箱时会看到一张很小的照片。这种情况是随机的,但大多数情况下,当我在浏览器中打开首次选项卡时,我可以观察到它。

我怎样才能使照片正确?

如果我打开开发工具(F12)问题就会消失。 在本地服务器上一切都很好,问题只是生产服务器。

这是一张太小的照片 Too small

这是我想要的照片 Good photo

import React, { useCallback, useRef } from 'react';
import { observer } from 'mobx-react-lite';
import LightGallery from 'lightgallery/react';
import lgZoom from 'lightgallery/plugins/zoom';
import lgVideo from 'lightgallery/plugins/video';
import { InitDetail } from 'lightgallery/lg-events';
import Img, { getPhotoURL } from '../Img';
import { LightGalleryMB } from '../../store/lightGallery';
import 'lightgallery/css/lightgallery.css';
import 'lightgallery/css/lg-video.css';
import 'lightgallery/css/lg-zoom.css';
export type TlgItem = { url: string; type: 'photo' | 'yt' | 'video' };
export interface ILightGalleryComponent {
  data: (TlgItem | undefined)[];
  state: LightGalleryMB;
}
const LightGalleryComponent = ({ data, state }: ILightGalleryComponent) => {
  let lightGallery = useRef<any>(null);

  const onInit = useCallback((d: InitDetail) => {
    if (d) {
      lightGallery.current = d.instance;
      state.setLightGallery(d);
    }
  }, []);

  const getVideo = (item: any) => {
    if ('type' in item && item.type === 'video') {
      const obj = {
        source: [
          {
            src: item.url,
            type: 'video/mp4',
          },
        ],
        tracks: [
          {
            src: '{/videos/title.txt',
            kind: 'captions',
            srclang: 'en',
            label: 'English',
            default: 'true',
          },
        ],
        attributes: { preload: false, playsinline: true, controls: true },
      };
      return JSON.stringify(obj);
    }
    return null;
  };

  return (
    <LightGallery
      elementClassNames="hidden"
      onInit={onInit}
      licenseKey="0000-0000-000-0000"
      speed={100}
      backdropDuration={100}
      plugins={[
        lgZoom,
        lgVideo,
      ]}
      counter
      autoplayFirstVideo
      autoplayVideoOnSlide
      closeOnTap
      closable
      getCaptionFromTitleOrAlt={false}
      download={false}
      addClass="custom-bg"
      mobileSettings={{
        showCloseIcon: true,
      }}
    >
      {data.map((item) => {
        return (
          <a
            key={item?.url}
            data-src={
              item && ['yt', 'photo'].includes(item.type)
                ? getPhotoURL(item?.url)
                : null
            }
            data-video={getVideo(item)}
            style={{
              cursor: 'pointer',
              height: 'inherit',
              display: 'block',
            }}
          >
            <Img
              width={'100%'}
              height={'100%'}
              src={item && item.url ? item.url : ''}
              title={''}
              alt={''}
              objectFit="cover"
            />
          </a>
        );
      })}
    </LightGallery>
  );
};

export default observer(LightGalleryComponent);

环境 浏览器和版本 - Chrome 版本 115.0.5790.110(官方版本)(64 位) 操作系统 - Windows (Next.js) lightGallery 版本 - ^2.7.1

我不知道。

javascript reactjs lightgallery next
© www.soinside.com 2019 - 2024. All rights reserved.