This project is read-only.

Creating <a href link to pdf files

Topics: Customizing Orchard, Writing modules
Aug 15, 2012 at 6:46 PM
Edited Aug 15, 2012 at 6:47 PM

I am trying to come up with an easy way for non-technical admins to add a link to a pdf file in Orchard.  Does anyone know of a way for an admin to browse for a pdf and then add it to a content type as a link such as: "<a href ="/OrchardLocal/Media/Default/Page/example.pdf">Example PDF</a>" ?

What I am looking for is similar to the Media Picker but for inserting links to pdf (and maybe Excel) files instead of just images.  It would be ideal for the admin to add the link to the body area of a content type using TinyMce.  Is this possible without having to create a module to implement this functionality?

BTW, I tried using both Media Picker and File Field to upload pdfs.  They both failed when uploading an 8mb pdf but worked with one that was 2mb.  Of course, Media Picker creates an image link if you choose insert.

Aug 16, 2012 at 4:52 PM

I am having the same problem think that this needs to be plug in made for the html editor used :( please someone make it happen! 

Aug 17, 2012 at 12:09 AM
Edited Aug 17, 2012 at 12:09 AM

You don't need something "like the media picker", you need the media picker. 1.x has recent changes that makes this work better than it used to.

You also need to change your web.config to allow IIS to accept bigger uploads.

Aug 17, 2012 at 1:21 AM
Edited Aug 17, 2012 at 3:24 PM

Thanks for the web.config reminder ( <httpRuntime requestValidationMode="2.0" maxRequestLength="10240" /> ) I was trying to use "Orchard CMS: Up and Running" as a sample pdf.  It is 8.7mb.  I guess the default is 4096.

It is possible to use Media Picker to get your file uploaded.  Just do not insert it from Media Picker (unless it is an image and you want to).  You can find your file later from the "Browse Media" tab in Media Picker. It will be under a folder named for the content type within which you uploaded it.  So, if you uploaded from a Page content type, it will be under a folder located at /Media/Default/Page .  You can click on the file in the list and it will put the url in the URL textbox.  You can copy this url and reference it in a Link Field somewhere else.  It is not a "3-click browse/upload/link insert", but it works.  Alternatively, you can just code the link in TinyCme html editor or into a Text Field with "Default Flavor" set to html.  Also, not very "unskilled-admin" friendly, but it works.

Aug 17, 2012 at 4:14 PM

C_astle has a better solution while working in TinyCme ( see ).  I had missed the link button in TinyCme 1. because it is only visible if you highlight some text and 2. because I need new glasses. It's really small.

Aug 20, 2012 at 5:04 PM

... I really need to actually learn javascript! but there are so many things to learn ...

in the media picker module

Modules\Orchard.MediaPicker\Scripts\MediaBrowser.js line: 245

I changed the 


I changed the html link builder to this below....

  function getImageHtml(data) {
        return html = '<a href="' + encodeURI(data.src) + '"' + getAttr("alt", data.alt || "")
            + getAttr("class", data["class"])
            + getAttr("target", "blank")
            + getAttr("style",
            + getAttr("align", data.align)
            + getAttr("width", data.width)
            + getAttr("height", data.height)
            + "> " + "Your Link" + "<a/>";

You would need to copy the module and call it say... "content tiny picker" and then change the button on the tinymce editor 


lose the media picker... which is not really an option.

Ideally I would like this to be implemented in the insert link box... I have no idea exactly how to do that