PluginProbe ʕ •ᴥ•ʔ
GenerateBlocks / 2.2.0
GenerateBlocks v2.2.0
trunk 1.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 2.0.0 2.0.1 2.0.2 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.3.0
generateblocks / src / blocks / image / index.js
generateblocks / src / blocks / image Last commit date
components 1 year ago css 2 years ago attributes.js 1 year ago edit.js 2 years ago editor.scss 3 years ago index.js 1 year ago save.js 4 years ago transforms.js 1 year ago
index.js
59 lines
1 /**
2 * WordPress dependencies
3 */
4 import { registerBlockType } from '@wordpress/blocks';
5 import { __ } from '@wordpress/i18n';
6
7 /**
8 * Internal dependencies
9 */
10 import edit from './edit';
11 import save from './save';
12 import transforms from './transforms';
13 import dynamicContentAttributes from '../../extend/dynamic-content/attributes';
14 import getIcon from '../../utils/get-icon';
15 import { getBlockAttributes } from '../../block-context';
16 import imageContext from '../../block-context/image';
17 import blockAttributes from './attributes';
18
19 const attributes = Object.assign(
20 {},
21 getBlockAttributes( blockAttributes, imageContext, generateBlocksDefaults.image ),
22 dynamicContentAttributes
23 );
24
25 registerBlockType( 'generateblocks/image', {
26 apiVersion: 3,
27 title: __( 'Image', 'generateblocks' ),
28 category: 'generateblocks',
29 description: __( 'Add images to your content to make a visual statement.', 'generateblocks' ),
30 icon: getIcon( 'image' ),
31 attributes,
32 edit,
33 save,
34 transforms,
35 __experimentalLabel: ( attrs, { context } ) => {
36 const customName = attrs?.metadata?.name;
37
38 if ( 'list-view' === context && customName ) {
39 return customName;
40 }
41
42 if (
43 context === 'list-view' &&
44 ! attrs.useDynamicData &&
45 ( attrs.alt || attrs.title )
46 ) {
47 return attrs.alt || attrs.title;
48 }
49
50 return __( 'Image', 'generateblocks' );
51 },
52 usesContext: [ 'postId', 'postType' ],
53 supports: {
54 className: false,
55 customClassName: true,
56 html: false,
57 },
58 } );
59