REDROOM
PHP 8.2.31
Path:
Logout
Edit File
Size: 3.01 KB
Close
/home/nshryvcy/radiantskinclinics.org/wp-content/plugins/extendify_old/src/Agent/lib/blocks.js
Text
Base64
import { rawHandler, serialize } from '@wordpress/blocks'; export const walkAndUpdateImageDetails = (inputs, newImage) => { const blocks = rawHandler({ HTML: inputs.previousContent }); const parser = new DOMParser(); const walk = (blocks) => blocks.map((block) => { if (['core/image', 'core/cover'].includes(block.name)) { const attrs = { ...block.attributes }; const url = inputs.url.includes('unsplash.com') ? inputs.url.split('?')[0] // For unsplash just match the base URL : inputs.url; const isMatchingId = attrs.id === inputs.imageId; const isMatchingUrl = attrs.url.startsWith(url); if (!isMatchingId && !isMatchingUrl) { // Not our image, return as is return { ...block, attributes: attrs }; } attrs.url = newImage.source_url || newImage.url; attrs.id = newImage.id; // Remove import class if present if (attrs.className) { attrs.className = attrs.className .split(' ') .filter((cn) => cn !== 'extendify-image-import') .join(' '); } // originalContent needs wp-image-{id} to match the new ID const originalContentDoc = parser.parseFromString( attrs.originalContent || block.originalContent || '', 'text/html', ); const img = originalContentDoc.querySelector('img'); if (!img) return { ...block, attributes: attrs }; // cover block wont have an image here img.setAttribute('src', newImage.source_url || newImage.url); const classList = img.className .split(' ') .filter((cn) => cn !== `wp-image-${inputs.imageId}`); classList.push(`wp-image-${newImage.id}`); img.className = classList.join(' '); attrs.originalContent = originalContentDoc.body.innerHTML; return { ...block, attributes: attrs }; } if (['core/media-text'].includes(block.name)) { const attrs = { ...block.attributes }; const url = inputs.url.includes('unsplash.com') ? inputs.url.split('?')[0] // For unsplash just match the base URL : inputs.url; // media-text block may not have all the attributes if the image was external. const isMatchingId = attrs?.mediaId === inputs.imageId; const isMatchingMediaLink = attrs?.mediaLink?.startsWith(url); const isMatchingMediaUrl = attrs?.mediaUrl?.startsWith(url); if (!isMatchingId && !isMatchingMediaLink && !isMatchingMediaUrl) { // Not our image, return as is return { ...block, attributes: attrs }; } attrs.mediaLink = newImage.source_url || newImage.url; attrs.mediaUrl = newImage.source_url || newImage.url; attrs.mediaId = newImage.id; // Remove import class if present if (attrs.className) { attrs.className = attrs.className .split(' ') .filter((cn) => cn !== 'extendify-image-import') .join(' '); } return { ...block, attributes: attrs }; } if (block.innerBlocks && block.innerBlocks.length > 0) { return { ...block, innerBlocks: walk(block.innerBlocks), }; } return block; }); const updatedBlocks = walk(blocks); return serialize(updatedBlocks); };
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 1 × Files: 14
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
__tests__
DIR
-
drwxr-xr-x
2026-04-28 02:40:01
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
blocks.js
3.01 KB
lrw-r--r--
2026-03-19 23:35:18
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
confetti.js
1.46 KB
lrw-r--r--
2026-03-19 23:35:18
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
editor.js
746 B
lrw-r--r--
2026-02-19 03:27:14
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
markdown.js
670 B
lrw-r--r--
2026-02-27 04:48:52
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
media-views.js
1.97 KB
lrw-r--r--
2026-02-27 04:48:52
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
media.js
1.48 KB
lrw-r--r--
2026-02-19 03:27:14
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
page-tours.js
723 B
lrw-r--r--
2025-09-25 20:59:30
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
redirects.js
640 B
lrw-r--r--
2026-02-19 03:27:14
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
svg-blocks-scanner.js
2.07 KB
lrw-r--r--
2026-02-19 03:27:14
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
svg-helpers.js
4.91 KB
lrw-r--r--
2026-02-19 03:27:14
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
tour-helpers.js
461 B
lrw-r--r--
2025-08-27 17:47:28
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
util.js
537 B
lrw-r--r--
2026-04-27 23:36:32
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
variant-classes.js
4.72 KB
lrw-r--r--
2025-12-17 19:09:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
wp.js
420 B
lrw-r--r--
2026-02-27 04:48:52
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).