Skip to content

Instantly share code, notes, and snippets.

@diger74
Last active November 28, 2024 13:20
Show Gist options
  • Select an option

  • Save diger74/742b518825663c640e3a51ab73014838 to your computer and use it in GitHub Desktop.

Select an option

Save diger74/742b518825663c640e3a51ab73014838 to your computer and use it in GitHub Desktop.
SELECT JSON_VALUE(ImageFile, '$.Identifier') AS Identifier
,JSON_VALUE(ImageFile, '$.Name') AS Name
,JSON_VALUE(ImageFile, '$.Extension') AS Extension
,JSON_VALUE(ImageFile, '$.Size') AS Size
,JSON_VALUE(ImageFile, '$.LastModified') AS LastModified
,LOWER(CONCAT(
'/assets/ContentItems/',
LEFT(ci.ContentItemGUID, 2),
'/',
ci.ContentItemGUID,
'/',
CAST(ClassFormDefinition AS XML).value('(/form/field[@columntype="contentitemasset"]/@guid)[1]', 'NVARCHAR(50)'),
'/',
JSON_VALUE(ImageFile, '$.Identifier'),
JSON_VALUE(ImageFile, '$.Extension')
)) AS FilePathOnDisk
FROM CMS_ContentItem ci
LEFT JOIN CMS_ContentItemCommonData cicd
ON cicd.ContentItemCommonDataContentItemID = ci.ContentItemID
LEFT JOIN CMS_ContentItemLanguageMetadata cilm
ON cicd.ContentItemCommonDataContentLanguageID = cilm.ContentItemLanguageMetadataContentLanguageID
AND cicd.ContentItemCommonDataContentItemID = cilm.ContentItemLanguageMetadataContentItemID
LEFT JOIN CMS_ContentLanguage cl
ON cl.ContentLanguageID = cilm.ContentItemLanguageMetadataContentLanguageID
LEFT JOIN CMS_Class c
ON ci.ContentItemContentTypeID = c.ClassID
LEFT JOIN DancingGoat_Image im
ON c.ClassName = 'DancingGoat.Image'
AND cicd.ContentItemCommonDataID = im.ContentItemDataCommonDataID
WHERE ci.ContentItemGUID = '279bb55f-81e3-4d93-9cff-8372dc34cdc5'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment