Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Francis 12 posts 43 karma points
    Mar 21, 2017 @ 09:54
    Francis
    0

    DAMP in Umbraco 7

    Hi,

    I have inherited a site which uses DAMP for images. I have successfully upgraded to Umbraco 7 but those image fieds are still DAMP and return DAMP objects. The library to get the objects out no longer works. If I change the field type will the images remain, or is there a way I could just get the images out of the CMS for now to display?

    Any help/advice would be appreciated.

    Thanks in advance.

  • Marc Goodson 2155 posts 14408 karma points MVP 9x c-trib
    Mar 21, 2017 @ 20:54
    Marc Goodson
    101

    Hi Francis

    I've upgraded a few Umbraco sites in the past that have used DAMP.

    You can change the property in Umbraco to be a Media Picker data type,

    (you'd then look to handle crops with the built in image cropper - migrating crops is a different story)

    but the problem is migrating the picked images that have their data and crop information stored in the DAMP XML format and not the ID of the Media Item that the Media picker would use.

    The XML data is stored in the dataNtext column of the cmsPropertyData table.

    The Media Picker would store the pickedId in the dataInt column.

    Running the following SQL against the database extracts the picked ID from within the XML, and puts it into the correct dataInt column for the Media picker:

    Update cmsPropertyData 
    set dataInt = CAST(dataNtext AS XML).value('(//Image/@id)[1]', 'int')
    where propertytypeid in (60,61,74) and dataNtext like '%<DAMP%'
    

    Where propertytypeid is the id of the property type that you are converting, in the example above I have three DAMP properties with Id 60,61 and 74.

    You are not actually deleting the DAMP xml from the dataNtext column, if it all goes wrong :-).

    regards

    Marc

  • Francis 12 posts 43 karma points
    Mar 22, 2017 @ 10:02
    Francis
    0

    Amazing. Thank you very much. I'll have a try and let you know how it goes.

  • Francis 12 posts 43 karma points
    Mar 28, 2017 @ 09:21
    Francis
    1

    For anyone else, the code above gets one value. But I tweaked the SQL a bit, so this should work for multiple values:

    Update cmsPropertyData 
    set dataNVarchar = REPLACE( CAST(dataNtext AS XML).query('data(//Image/@id)').value('.','nvarchar(80)'), ' ', ',')
    where dataNtext like '%<DAMP%'
    

    Thanks Marc :).

  • Marc Goodson 2155 posts 14408 karma points MVP 9x c-trib
    Mar 28, 2017 @ 10:24
    Marc Goodson
    0

    Awesome Francis

    I only ever had a single media item picked via DAMP!

Please Sign in or register to post replies

Write your reply to:

Draft