@pantheon-systems/p1-media 0.4.3 → 0.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -2773,6 +2773,8 @@ function MediaImage({
2773
2773
  mediaBaseUrl,
2774
2774
  transform,
2775
2775
  alt,
2776
+ loading = "lazy",
2777
+ decoding = "async",
2776
2778
  ...rest
2777
2779
  }) {
2778
2780
  const props = getMediaProps(image, { mediaBaseUrl, transform });
@@ -2782,6 +2784,8 @@ function MediaImage({
2782
2784
  {
2783
2785
  src: props.src,
2784
2786
  alt: alt ?? props.alt,
2787
+ loading,
2788
+ decoding,
2785
2789
  ...props.width !== void 0 ? { width: props.width } : {},
2786
2790
  ...props.height !== void 0 ? { height: props.height } : {},
2787
2791
  ...rest
@@ -2814,7 +2818,9 @@ function MediaFigure({
2814
2818
  mediaBaseUrl,
2815
2819
  transform,
2816
2820
  className,
2817
- captionClassName
2821
+ captionClassName,
2822
+ loading = "lazy",
2823
+ decoding = "async"
2818
2824
  }) {
2819
2825
  const props = getMediaProps(image, { mediaBaseUrl, transform });
2820
2826
  if (!props.src) return null;
@@ -2825,6 +2831,8 @@ function MediaFigure({
2825
2831
  {
2826
2832
  src: props.src,
2827
2833
  alt: props.alt,
2834
+ loading,
2835
+ decoding,
2828
2836
  ...props.width !== void 0 ? { width: props.width } : {},
2829
2837
  ...props.height !== void 0 ? { height: props.height } : {}
2830
2838
  }
@@ -2856,19 +2864,29 @@ function createMediaFigureBlock(options) {
2856
2864
  schema,
2857
2865
  className,
2858
2866
  captionClassName,
2859
- placeholder = "Choose a photo from the media library"
2867
+ placeholder = "Choose a photo from the media library",
2868
+ defaultLoading = "lazy"
2860
2869
  } = options;
2861
2870
  return {
2862
2871
  label,
2863
2872
  fields: {
2864
2873
  // `p1-media` is registered by createMediaPlugin via overrides.fieldTypes,
2865
2874
  // so it is not part of Puck's built-in Field union.
2866
- photo: { type: "p1-media", label: fieldLabel }
2875
+ photo: { type: "p1-media", label: fieldLabel },
2876
+ loading: {
2877
+ type: "radio",
2878
+ label: "Loading",
2879
+ options: [
2880
+ { label: "Lazy", value: "lazy" },
2881
+ { label: "Eager", value: "eager" }
2882
+ ]
2883
+ }
2867
2884
  },
2868
2885
  defaultProps: {
2869
- photo: null
2886
+ photo: null,
2887
+ loading: defaultLoading
2870
2888
  },
2871
- render: ({ photo }) => {
2889
+ render: ({ photo, loading }) => {
2872
2890
  const { src } = getMediaProps(photo ?? null, { mediaBaseUrl });
2873
2891
  if (!src) {
2874
2892
  return /* @__PURE__ */ jsx14("div", { style: placeholderStyle, children: placeholder });
@@ -2881,7 +2899,8 @@ function createMediaFigureBlock(options) {
2881
2899
  transform,
2882
2900
  schema,
2883
2901
  className,
2884
- captionClassName
2902
+ captionClassName,
2903
+ loading: loading === "eager" ? "eager" : "lazy"
2885
2904
  }
2886
2905
  );
2887
2906
  }