MCPcopy Create free account
hub / github.com/claude-code-best/claude-code / extractImagesFromValue

Function extractImagesFromValue

src/utils/messageQueueManager.ts:392–415  ·  view source on GitHub ↗

* Extract images from ContentBlockParam[] and convert to PastedContent format. * Returns empty array for string values or if no images found.

(
  value: string | ContentBlockParam[],
  startId: number,
)

Source from the content-addressed store, hash-verified

390 * Returns empty array for string values or if no images found.
391 */
392function extractImagesFromValue(
393 value: string | ContentBlockParam[],
394 startId: number,
395): PastedContent[] {
396 if (typeof value === 'string') {
397 return []
398 }
399
400 const images: PastedContent[] = []
401 let imageIndex = 0
402 for (const block of value) {
403 if (block.type === 'image' && block.source.type === 'base64') {
404 images.push({
405 id: startId + imageIndex,
406 type: 'image',
407 content: block.source.data,
408 mediaType: block.source.media_type,
409 filename: `image${imageIndex + 1}`,
410 })
411 imageIndex++
412 }
413 }
414 return images
415}
416
417export type PopAllEditableResult = {
418 text: string

Callers 1

popAllEditableFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected