Copied to clipboard

Flag this post as spam?

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


  • carmen lazar 10 posts 80 karma points
    Oct 11, 2016 @ 08:33
    carmen lazar
    0

    Url is empty for Media

    After getting an image as IPublishedContent, I try to get the Url or use the GetCropUrl method and they both return nothing.

    I first get the a folder using Umbraco.TypedMedia, and then I get the Children of the folder(I filter them out to be only images). Some of the Children return an empty Url. If I try to get property value for the property "umbracoAlias", it also returns nothing, but if I use the method HasValue("umbracoAlias") it returns true.

    This issue doesn't come up for all media items. I searched in the index to see the difference between an image that works and one that doesnt.

    This one works: enter image description here

    This one doesnt: enter image description here

    Has anyone encountered this issue before or can anyone give me a hint or an idea as to why this could be happening?

    Umbraco version 7.5.3 assembly: 1.0.6092.24019

  • Aleksey Gerasimov 31 posts 95 karma points
    Oct 11, 2016 @ 09:06
    Aleksey Gerasimov
    0

    I doubt that Media can be IPublishedContent. Maybe you need something like IMedia?https://our.umbraco.org/Documentation/Reference/Management/Models/Media

  • Micha Somers 134 posts 597 karma points
    Oct 11, 2016 @ 09:14
    Micha Somers
    0

    Although I don't know the reason why, it is remarkable that one node has a nodeName with an extension .jpg in it and the other doesn't.

    nodeName: Stella-1.jpg <==> dialog samtale helsingoer (without .jpg)

    Investigating the real filename probably gives an indication of what goes wrong. If for example Stella-1.jpg actually refers to a file Stella-1.jpg.jpg, try to see if it works when you rename it.

  • carmen lazar 10 posts 80 karma points
    Oct 11, 2016 @ 09:25
    carmen lazar
    0

    @Aleksey

    I am pretty sure you can. I have done a lot of times and still do it. If you use Umbraco.TypedMedia you get media items as IPublishedContent.

    @Micha I think that when the Stella image was uploaded, the name was set by default as the fileName. Since nobody changed it it stayed like that, while the dialog image name was changed manually by someone. I don't think the name affects the url because the url will always be path to the file, while the name can be edited.

  • Micha Somers 134 posts 597 karma points
    Oct 11, 2016 @ 09:47
    Micha Somers
    0

    Hi Carmen,

    Sure, renaming may not solve it, but the original filename may explain what goes wrong. Do you know the original filename for dialog-samtale-helsingoer. Does it contain special symbols that Umbraco transformed to something different in the urlname?

  • carmen lazar 10 posts 80 karma points
    Oct 11, 2016 @ 10:01
    carmen lazar
    0

    Hi Micha,

    I don't know the original filename.

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Oct 11, 2016 @ 10:03
    Ismail Mayat
    0

    Carmen,

    The only time i have seen this happen is when the index is out of sync. Try rebuilding your internal and external index. If that does not work try re saving media item with broken link.

    Also can you double check your umbraco log file see if there are any indexing errors in there?

    Regards

    Ismail

  • carmen lazar 10 posts 80 karma points
    Oct 11, 2016 @ 10:35
    carmen lazar
    0

    Hi Ismail

    This is after reindexing. I can try to save the image and look more in the log files and see if there's anything I missed.

  • carmen lazar 10 posts 80 karma points
    Oct 11, 2016 @ 10:57
    carmen lazar
    0

    Looked in the logs and I cannot find indexing errors.

  • Micha Somers 134 posts 597 karma points
    Oct 11, 2016 @ 11:21
    Micha Somers
    0

    Hi Carmen,

    Can you see the (problematic) media file in Umbraco (under Media)?

    If no, could you check if it's in the Recycle Bin. If it has been deleted, the file might still be available on the website but is (probably) not being indexed anymore.

    If yes, which file is it linked to?

  • carmen lazar 10 posts 80 karma points
    Oct 11, 2016 @ 11:41
    carmen lazar
    0

    Hi Micha,

    The image is not deleted. I can see it in the Media section in Umbraco and if I look at the url saved in the index, I can find it on the server.

    I forgot to mention that if I use the mediaService I can get the value of "umbracoFile". It is only if I try to get it from the IPublishedContent, the value is empty.

  • Alex Skrypnyk 6175 posts 24186 karma points MVP 8x admin c-trib
    Oct 11, 2016 @ 16:58
    Alex Skrypnyk
    0

    Hi Carmen,

    Try to use MediaService - if it will return Url of image - than problem with cache or index.

    MediaService works with database directly, so if it will return empty image - the problem with database.

    Read more - https://our.umbraco.org/documentation/reference/management/services/mediaservice

    Be aware - mediaService isn't recommended to use on the clientSide in Razor for example, so this experiment only for this case.

    Thanks,

    Alex

  • Micha Somers 134 posts 597 karma points
    Oct 11, 2016 @ 12:19
    Micha Somers
    0

    Hi Carmen,

    I am not sure if, after changing a media item, the updated media item will "automatically" be available in the mediaservice. I would hope it is, but hopefully someone with more experience on that topic can tell more about it ...

    However, since the mediaLink=null for the problematic image, I wonder:

    Is this image published somewhere on a page? If it is, is it possible to republish that page?

  • Micha Somers 134 posts 597 karma points
    Oct 11, 2016 @ 14:39
    Micha Somers
    0

    Mmm ... just found the following post that looks related to this issue:

    https://our.umbraco.org/forum/developers/razor/57936-TypedMedia-URL-is-empty

    If your log contains the text:

    Dropping property "image" because it does not belong to the content type.

    it probably is about the same problem.

    Unfortunately it does not really give a solid solution but several suggestions are given (and also a lot that did not help, so you do not have to try these ones anymore)

    One of the interesting looking suggestions (not tried myself) is about pulling media from the database via the old api:

    var media = new umbraco.cms.businesslogic.media.Media(mediaID);
    if( media != null && media.ContentType.Alias != "Folder" )
    {
      return media.getProperty("umbracoFile").Value.ToString();
    }
    

    Hope this will help finding a solution ...

  • carmen lazar 10 posts 80 karma points
    Oct 11, 2016 @ 16:49
    carmen lazar
    1

    Ok, I figured out what is wrong. The umbracoFile property is supposed to store a json object with the values for the image cropper. The json object has a property called focal point which is supposed to contain two properties called top and left and they store percentage values (if left is 0.5 it means the focal point is in the middle of the image horizontally). The image that fails has a focal point with properties called left and right.

    Thank you all for your answers and the time you put in to help me.

  • Micha Somers 134 posts 597 karma points
    Oct 12, 2016 @ 07:19
    Micha Somers
    0

    Good to see that you found the difference that explains why it caused problems!

    Just out of curiousity, but do you also know why the properties for the focal point were named differently? Is it something in Umbraco that caused it?

  • carmen lazar 10 posts 80 karma points
    Oct 12, 2016 @ 07:29
    carmen lazar
    0

    I don't think this is an issue coming from Umbraco. We used to have our own image cropper on images and I think this is old data left from the old image cropper.

Please Sign in or register to post replies

Write your reply to:

Draft