import { createElement } from '@wordpress/element'
import {
useBlockProps,
__experimentalUseBorderProps as useBorderProps,
} from '@wordpress/block-editor'
import classnames from 'classnames'
import { addQueryArgs, removeQueryArgs } from '@wordpress/url'
import { useUserAvatar } from '../../hooks/use-user-avatar'
const ImagePreview = ({
postId,
postType,
attributes,
attributes: { avatar_size, imageAlign, has_field_link },
}) => {
const blockProps = useBlockProps({
className: classnames('ct-dynamic-media wp-block-image', {
[`align${imageAlign}`]: imageAlign,
}),
style: {},
})
const borderProps = useBorderProps(attributes)
const avatar = useUserAvatar({
postId,
postType,
})
let maybeUrl = '#'
const doubledSizedSrc = addQueryArgs(removeQueryArgs(avatar.src, ['s']), {
s: avatar_size * 2,
})
const imageStyles = {
...borderProps.style,
}
let content = (
)
if (has_field_link) {
content = {content}
}
return {content}
}
export default ImagePreview