import { __ } from '@wordpress/i18n'; import { InspectorControls, useBlockProps } from '@wordpress/block-editor'; import { PanelBody, ToggleControl, SelectControl, __experimentalInputControl as InputControl, } from '@wordpress/components'; export const edit = ( props ) => { const { attributes, setAttributes, context } = props; const blockProps = useBlockProps(); const { lpCourseData } = context; const courseImage = lpCourseData?.image || '
';
const sizeOption = [
{ label: 'Thumbnail', value: 'thumbnail' },
{ label: 'Medium', value: 'medium' },
{ label: 'Large', value: 'large' },
{ label: 'Full', value: 'full' },
{ label: 'Custom', value: 'custom' },
];
const getStyledCourseImage = () => {
if (
lpCourseData?.image &&
attributes.size === 'custom' &&
attributes.customWidth === 500 &&
attributes.customHeight === 300
) {
return lpCourseData?.image;
}
let width = 2560;
let height = 2560;
if ( attributes.size === 'thumbnail' ) {
width = 150;
height = 150;
}
if ( attributes.size === 'medium' ) {
width = 300;
height = 300;
}
if ( attributes.size === 'large' ) {
width = 1024;
height = 724;
}
if ( attributes.size === 'full' ) {
width = 2560;
height = 2560;
}
if ( attributes.size === 'custom' ) {
if ( attributes.customWidth && attributes.customWidth > 0 ) {
width = attributes.customWidth;
}
if ( attributes.customHeight && attributes.customHeight > 0 ) {
height = attributes.customHeight;
}
if ( attributes.customWidth == 0 ) {
width = 2560;
}
if ( attributes.customHeight == 0 ) {
width = 2560;
}
}
const ratio = width / height;
return `
`;
};
return (
<>