Copied to clipboard

Flag this post as spam?

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


  • Andreas Pfanner 196 posts 314 karma points
    Mar 27, 2012 @ 09:51
    Andreas Pfanner
    0

    Get Media by type (4.7.1)

    Hi,

    I'm trying to recursively get all media items of a specific (custom) media type, starting from a defined node:

    List<Mediagalleries uQuery.GetMediaByXPath("descendant::*[@id='"+startNode+"']/descendant::*[@nodeTypeAlias='ImageGalleries']");

    This works, but performance isn't quite good, and I actually only have a few hundred items in the Media library. The query needs about 10 seconds. Caching is a way to optimize, but the first call keeps slow.

    Any idea/alternatives to my approach?

    Best Regards

    Andreas

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Mar 27, 2012 @ 10:16
    Hendy Racher
    0

    Hi Andreas,

    Internally that method hits the database and builds an Xml doc from the rows of media items in cmsContentXml (there isn't an in memory xml doc of media), but perhaps, as you say, caching the media Xml might help ?

    XmlDocument mediaXml = uQuery.GetPublishedXml(uQuery.UmbracoObjectType.Media);

    I wonder how this can be added internally to uComponents - perhaps the addition of an event handler that on save of any Media causes that cache to be wiped ?

    HTH,

    Hendy

Please Sign in or register to post replies

Write your reply to:

Draft