components
4 years ago
css
4 years ago
block.json
4 years ago
edit.js
4 years ago
editor.scss
4 years ago
index.js
4 years ago
save.js
4 years ago
transforms.js
4 years ago
transforms.js
47 lines
| 1 | /** |
| 2 | * WordPress dependencies |
| 3 | */ |
| 4 | import { createBlock } from '@wordpress/blocks'; |
| 5 | |
| 6 | const transforms = { |
| 7 | from: [ |
| 8 | { |
| 9 | type: 'block', |
| 10 | blocks: [ 'core/image' ], |
| 11 | transform: ( { id, url, sizeSlug } ) => { |
| 12 | return createBlock( 'generateblocks/image', { |
| 13 | mediaId: id, |
| 14 | mediaUrl: url, |
| 15 | sizeSlug, |
| 16 | } ); |
| 17 | }, |
| 18 | }, |
| 19 | { |
| 20 | type: 'block', |
| 21 | blocks: [ 'core/post-featured-image' ], |
| 22 | transform: ( { sizeSlug } ) => { |
| 23 | return createBlock( 'generateblocks/image', { |
| 24 | useDynamicData: true, |
| 25 | dynamicContentType: 'featured-image', |
| 26 | sizeSlug, |
| 27 | } ); |
| 28 | }, |
| 29 | }, |
| 30 | ], |
| 31 | to: [ |
| 32 | { |
| 33 | type: 'block', |
| 34 | blocks: [ 'core/image' ], |
| 35 | transform: ( { mediaId, mediaUrl, sizeSlug } ) => { |
| 36 | return createBlock( 'core/image', { |
| 37 | id: mediaId, |
| 38 | url: mediaUrl, |
| 39 | sizeSlug, |
| 40 | } ); |
| 41 | }, |
| 42 | }, |
| 43 | ], |
| 44 | }; |
| 45 | |
| 46 | export default transforms; |
| 47 |