Copied to clipboard

Flag this post as spam?

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


  • atze187 160 posts 215 karma points
    Nov 03, 2009 @ 10:59
    atze187
    0

    Media folder name

    Hi,

    is there a way to force the media files being served with the real folder names entered in the media section instead of the folder IDs (so its /media/pdf/file.pdf instead of /media/644/file.pdf)?

    Thx,
    André

  • Thomas Höhler 1237 posts 1709 karma points MVP
    Nov 03, 2009 @ 11:02
    Thomas Höhler
    0

    Not with the build in methods. You can either choose to place the medias in subfolders with the property ids (/media/644/file.pdf) or to use it in a flat manner (/media/644_file.pdf [or similiar])

    hth, Thomas

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Nov 03, 2009 @ 11:09
    Dirk De Grave
    0

    Hi André,

    As thomas is suggesting, you can't out-of-the-box, but you can if you have some programming knowledge. You can either change location of a uploaded file on create or update of a media file using the event system (be aware tho to update all relevant properties as eg. the rich text editor uses path info to build the links) or build your own upload datatype and store all info yourself.

    For some more background info on events, see these wiki pages starting here.

     

    Hope this helps.

    Regards,

    /Dirk

  • atze187 160 posts 215 karma points
    Nov 03, 2009 @ 11:12
    atze187
    0

    Thanks for that. It would have been nice, but actually isn't too bad.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Dec 28, 2009 @ 15:37
    Jan Skovgaard
    0

    Hi guys

    Would it be very hard to make a structure like this, when you upload a PDF file for instance?

    /media/pdf/(id)/first.pdf
    /media/pdf/(id)/second.pdf
    etc.

    Is it possible and if so, what should one then be aware of?

    I need to make sure that I can block access to the PDF files through robots.txt so they don't get indexed by search engines but unfortunately one can't trust the * to "work" in a robots.txt file...otherwise it would have been easy and I would not have a problem :)

    Looking forward to hear from you guys.

    /Jan

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Dec 28, 2009 @ 15:52
    Dirk De Grave
    1

    Yup, it can be done, and there's several possibilities:

    Inherit from the existing uploadField implementation and 'override' the Save() method. Bit of a hack, as you'll have to use the new keyword the hide the existing implementation (but that works). Also, as your class will be different from the uploadField class, you'll have to build your loadMedia implementation which is used to build the media tree and media picker dialog (as those rely on the guid of the media type)

     

    Hope this helps.

    Regards,

    /Dirk

     

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Dec 30, 2009 @ 14:14
    Jan Skovgaard
    0

    Hi Dirk

    Thanks for your pointers. I must admit I'm not sure that I myself have the skills to do what is neccesary to make it work. To me it sounds like it's going to take long time, to get it right.

    I'm also thinking it should not be neccesary to make a change to the media library to make sure that PDF files are not being crawled by search engines. Does anyone have a simple solution to manage that task? As far as I know it's not possible to use *.pdf in robots.txt.

    Any thoughts?

    /Jan

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 11, 2010 @ 16:27
    Jan Skovgaard
    0

    Hi again

    I got some help from a colleague today to help me achieve my goal. Basically we made a new datatype where we copied the original soruce files, changed name and guid of course and then we made an if sequence to see if the uploaded file ends with "PDF". If so we create a PDF folder in the library. Works like a charm.

    However there is still one problem though. At the moment it's not possible to use the media-picker in the rich text editor to select the PDF file, when one wants to insert a link to it on a textpage.

    In the dialogue it's visible but with a grey color, instead of black. Since it's grey it cannot be selected and no link is being inserted.

    What is it that we need to do further to finish the job?

    /Jan

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jan 11, 2010 @ 16:54
    Dirk De Grave
    1

    Yup, you need to add your new datatype's guid to the list of LinkableMediaDatatypes either on application startup or inherit from loadMedia and override the GetLinkValue(Media m, string nodeLink) method. I prefer the second method but that requires an additional db change (loadMedia replace by your custom 'load' class)

     

    Cheers,

    /Dirk

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 11, 2010 @ 21:22
    Jan Skovgaard
    0

    Thank you very much Dirk. I will look into it first thing tomorrow. I love this community :-)

    /Jan

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Feb 16, 2010 @ 14:23
    Jan Skovgaard
    0

    Hello again

    I'm experiencing something odd. I got the stuff with the media-picker working by following Dirk's suggestion but all of the sudden it does not work anymore.

    I tried changing the GUID to see if that would fix it but it does'nt. I'm a bit puzzled about this. I don't think anyone else could have overwritten er changed anything.

    In my pdfDataTypeUploadField.cs I have the following code for the GUID

    public override Guid Id
    {
        get { return new Guid("{C622B4B4-F5DC-47a6-840F-696B9A20Y309}"); }
    }

    and in my PdfUploadField.cs I have the following

    public PdfUploadField(umbraco.interfaces.IData Data, string ThumbnailSizes)
    {
        _data = (umbraco.cms.businesslogic.datatype.DefaultData)Data;
        _thumbnails = ThumbnailSizes;
            if (!umbraco.loadMedia.LinkableMediaDataTypes.Contains(new Guid("{C622B4B4-F5DC-47a6-840F-696B9A20Y309}")))            umbraco.loadMedia.LinkableMediaDataTypes.Add(new Guid("{C622B4B4-F5DC-47a6-840F-696B9A20Y309}"));
    }

    Is there anything else that I need to do to get this to work properly? Something that I have missed?

     

    /Jan

Please Sign in or register to post replies

Write your reply to:

Draft