Copied to clipboard

Flag this post as spam?

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


  • snitram 27 posts 48 karma points
    Jul 14, 2010 @ 12:59
    snitram
    0

    Media path challenge

    Hi everyone,

    I'm hoping for some help here.

    I'm currently working on a webshop for a client. I'm going to replicate products, categories etc. to the website once every day. My challenge is as follows:

    I'm planning on connecting the images to each product, by letting the client upload all the images to a specified folder in Umbraco (via. Media multiupload), and then merging the product id with ".jpg" ie. "010101.jpg" to create the image name when I need to show the image in the shop. But my problem is, that I dont know:

    1) The id of the media item in Umbraco
    2) The path of the media item in Umbraco

    Therefore I cannot merge the full path to the image ("/media/145/010101.jpg").

    I would greatly appreciate any takes on solving my challenge :-)

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Jul 14, 2010 @ 13:10
    Matt Brailsford
    0

    Hi Martin,

    You could try using Hendy's helper methods (http://blog.hendyracher.co.uk/umbraco-helper-class/) and use the GetMediaFromXpath method to pull back media items based on the name. Not 100% sure on the XPath, but shouldn't be too difficuilt.

    I'm not sure if this is true of Hendys helper methods, but I know Media calls are quite expensive in terms of DB calls, so if this is a problem you could do a direct DB query.

    Matt

  • snitram 27 posts 48 karma points
    Jul 14, 2010 @ 13:28
    snitram
    0

    Hi Matt,

    Thanks a bunch for your suggestions.

    I was onto a direct DB query earlier, but I've unsuccessfully searched for the schema of the Media DB. Can you point me in the right direction?

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Jul 14, 2010 @ 13:33
    Matt Brailsford
    0

    Hi Martin,

    There is now definitive place, but you could try the following:

    http://blog.hendyracher.co.uk/umbraco-database-part-2/

    http://www.farmcode.org/post/2010/06/15/Umbraco-41-Database-Structure.aspx

    Alternativley, just ask if you are having any specific problems, I know a little about the DB, but the main thing to bare in mind is that everything is a node, so everything (content wise) holds an entry in the umbracoNode table.

    Matt

  • snitram 27 posts 48 karma points
    Jul 16, 2010 @ 08:10
    snitram
    0

    Hi Matt,

    I ended up going the DB way, and it works like a charm.

    Thanks for your help

  • Sebastiaan Janssen 5045 posts 15477 karma points MVP admin hq
    Jul 16, 2010 @ 08:19
    Sebastiaan Janssen
    0

    If you're querying the database directly (and use paramterized queries) then that's just fine. If you're doing it through the api, in versions lower than 4.5, you will experience a serious performance penalty on each pageload. Also, if you're on the pre-4.5 version, check out my "cultiv media cache" package, that will save you many database calls in the frontend. Media caching is built in in 4.5 though.

  • snitram 27 posts 48 karma points
    Jul 16, 2010 @ 08:30
    snitram
    1

    I'm querying the database directly - and furthermore I'm doing it when the data is replicated. That way, when I need to render the presentation frontend, I already know the image paths.

    But thanks for your information - It's nice to have peops watching your back :-)

Please Sign in or register to post replies

Write your reply to:

Draft