import Container from "@/components/Container/Container";
import Section from "@/components/Section/Section";
import Thumbnail from "@/components/Thumbnail/Thumbnail";
import { getCachedMedia } from "@/services/wp";


const ImageWithCaption = async (props: { [rest: string]: any }) => {
  const classes = ["rounded-xl"];

  if (!props.image_desktop) return <></>;

  const media = await getCachedMedia(props.image_desktop);


  if (!media) return <></>;

  return (
    <Container id={props.anchor}>
      <Section gridArea="wide">
        <Thumbnail
          width={1785}
          height={750}
          imageUrl={media.source_url}
          alt={media.alt ? media.alt : props.caption}
          fixedAspectRatio={false}
        />
        {props.caption && <h5 className="mt-xs">{props.caption}</h5>}
      </Section>
    </Container>
  );
};

export default ImageWithCaption;
