Copied to clipboard

Flag this post as spam?

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


  • Cody Boucher 2 posts 93 karma points c-trib
    Aug 26, 2019 @ 12:52
    Cody Boucher
    1

    cmsMedia has NULL mediaPath when umbracoMediaPath isn't "~/media"

    <add key="umbracoMediaPath" value="~/relocatemedia" />
    

    Setting this variable to something other than media gets a NULL value in the cmsMedia table in the mediaPath column.

    I'm able to add media but the thumbnails don't work properly. The pathing to the images also works but during the process of picking an image it treats the images as folder paths and blocks the selection.

    I manually updated the cmsMedia table to the path pulled from dataNtext from cmsPropertyData and the thumbnails started working.

    Am I missing something?

    UPDATE media
    SET media.mediaPath = JSON_VALUE(convert(nvarchar(max),d.dataNtext),'$.src') 
    FROM cmsMedia media 
    JOIN cmsPropertyData d ON d.contentNodeId = nodeId AND d.dataNvarchar IS NULL
    

    Running the above query fixes my issue but I'd rather not have to run that in every environment.

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    Aug 29, 2019 @ 21:45
    Alex Skrypnyk
    0

    Hi Cody

    Did you solve this issue?

    Thanks, Alex

  • Cody Boucher 2 posts 93 karma points c-trib
    Sep 06, 2019 @ 14:16
    Cody Boucher
    100

    This issue has been resolved. I submitted a PR to get it fixed and it got included in the 7.15.3 release.

    https://github.com/umbraco/Umbraco-CMS/issues/6202

  • MuirisOG 382 posts 1284 karma points
    Oct 24, 2019 @ 13:13
    MuirisOG
    1

    Only 24 records made it into the cmsMedia table when upgrading from 7.5.14 to7.15.3, so I used the script below.

    Just beware to use the correct propertyTypeIds for your database, and if your version of SQL Server has JSON (and trim, for that matter), you may want to change this script.

    It's not a catchall, but the pattern matching in both parts of the union caught most of the images in our database.

    And please, don't use it without testing it out on a test system first, or if you are in any way unsure.

    And, check your data afterwards.

    /*
      Details: Populating the cmsMedia folder from the cmsProperty table for images
    */
    delete from cmsMedia;
    
    insert into cmsMedia
           (nodeId,versionId,mediaPath)
    select p.contentNodeId,
           versionId,
           rtrim(ltrim(replace(substring(dataNtext,patindex('%src: ''%', dataNtext)+4,patindex('%'',%', substring(dataNtext,patindex('%src: ''%', dataNtext)+5,len(cast(dataNtext as nvarchar(max)))))), '''',''))) as pathname
           from cmsPropertyData p
           where p.propertytypeid in (6,24)
           and patindex('%src: %', datantext) > 0
    union
           select p.contentNodeId,
           versionId,
           rtrim(ltrim(replace(substring(dataNtext,patindex('%src": %', dataNtext)+6,patindex('%"%', substring(dataNtext,patindex('%src": %', dataNtext)+7,len(cast(dataNtext as nvarchar(max)))))), '"',''))) as pathname
           from cmsPropertyData p
           where p.propertytypeid in (6,24)
           and patindex('%src": %', datantext) > 0
    ;
    

    Thanks

    Muiris

Please Sign in or register to post replies

Write your reply to:

Draft