Copied to clipboard

Flag this post as spam?

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


  • Brett Palmer 8 posts 98 karma points
    Sep 28, 2023 @ 14:01
    Brett Palmer
    0

    Convert Search Results Including umbracoMediaArticleto IPublishedContent

    I'm trying to include umbracoMediaArticle in my LuceneSearchResults. When I get a search result based on a page, I can select it as IPublishedContent with:

    IEnumerable<IPublishedContent> SearchResultsDefault = LuceneSearchResultsDefault.Select(x => _umbracoHelper.Content(x.Id));
    

    When I am trying to deal with a search result that is umbracoMediaArticle, the following results in a collection of nulls:

    IEnumerable<IPublishedContent> SearchResultsMedia = LuceneSearchResultsMedia.Select(x => _umbracoHelper.Media(x.Id));
    

    I swear I had this working at some point last night. Can anyone shed light on what I'm doing wrong with UmbracoHelper.Media(ID)??

  • Brett Palmer 8 posts 98 karma points
    Sep 28, 2023 @ 16:48
    Brett Palmer
    0

    After line 70, I have a collection of ISearchResult. Each of them includes an ID. After line 71 I try to use that ID to get IPublishedContent. It returns a collection of nulls

    enter image description here

  • Brett Palmer 8 posts 98 karma points
    Oct 06, 2023 @ 12:43
    Brett Palmer
    0

    I found that this wasn't happening for media items I freshly added to the library. I found this wasn't happening for media items that had been added to the library that I opened and re-saved.

    All of the media had been added in a different environment. I took the DB and media, brought it locally and started writing this code. Somewhere in there was an update to Umbraco 12.2.0 as well as me adding additional fields to the Umbraco Media Article doc type. Some combination of those things:

    • Pulling site down locally
    • Umbraco update
    • Update to doc type

    Made it so I just had to save any files I wanted to fetch before fetching them. No clarity on why UmbracoHelper.media() couldn't fetch them even though they existed. I'd expect that if I added new fields and didn't save the individual media item: that the fields wouldn't be available but I didn't think it would be impossible get it as IPublishedContent.

Please Sign in or register to post replies

Write your reply to:

Draft