Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save eerrecart/6e892d81abff922590c3 to your computer and use it in GitHub Desktop.
Save eerrecart/6e892d81abff922590c3 to your computer and use it in GitHub Desktop.
Umbraco - Get all media ids referenced on documents
-- native image picker editor data type => EF94C406-9E83-4058-A780-0375624BA7CA
DECLARE @dataTypeSearch NVARCHAR(50)
SET @dataTypeSearch = 'EF94C406-9E83-4058-A780-0375624BA7CA'
-- get all datatypes using the image picker tool
SELECT * FROM cmsDataType as DT
INNER JOIN umbracoNode N on N.id = DT.nodeId
WHERE DT.controlId LIKE @dataTypeSearch
-- all properties using this DT
SELECT * FROM cmsPropertyType WHERE dataTypeId IN (1066, 1067, 142511)
-- retrive all values stored in properties of type : 1066, 1067 on this case the Id of the media selected
SELECT DISTINCT
--N.text
PD.dataNvarchar-- or dataNtext or dataDate
FROM
UmbracoNode N
INNER JOIN
cmsPropertyData PD ON PD.contentNodeId = N.id
WHERE
propertytypeid IN (SELECT DISTINCT id FROM cmsPropertyType WHERE dataTypeId IN (1066, 1067))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment