MCPcopy Index your code
hub / github.com/codeaashu/claude-code / extractImagesFromValue

Function extractImagesFromValue

src/utils/messageQueueManager.ts:390–413  ·  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

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

Callers 1

popAllEditableFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected