I have a document library where I only want users to upload images file types and nothing else.

First question, when a user selects 'Browse', can I select the accepted extensions filter by default? That way I can lock it down to image extensions like .png, .jpg etc

Second, and more importantly for my situation, can I change the default title from 'Add a document' to 'Add an Image'?

enter image description here

  • Why don't you simply use a Picture Library instead of a Document Library ? May 31 '14 at 14:19
  • Good question..It's actually an assets library that I'm using which has more attractive features than a Pic library. Also, a picture library doesn't restrict the upload type and I would still want to change that default 'Add a Picture' title May 31 '14 at 17:26

How to change the Add a document text:

Add a Script Editor web part and place the following code in it (requires jQuery).


function renameTitle(){
    $('[title^="Upload"]').on('click', function(){  
           $('#dialogTitleSpan').text("Add an image"); 

How to restrict file uploads to images only:

The file input element found in Upload.aspx has this piece of code:


You can override the function CheckAssetLibMediaExtension and add your logic to check allowed file extensions. This function needs to reside in your MasterPage (either add it to it directly or include a reference to a javascript file via ScriptLink).

Here's an example of a possible implementation:

CheckAssetLibMediaExtension = function(){    
  var allowedExtensions = /jpg|png|gif/;
  var inputFile = $("input[name$='InputFile']").val();
  var ext = inputFile.substr(inputFile.lastIndexOf('.') + 1);
  if (!allowedExtensions.test(ext)){
  } else{
  • I'm playing with this trying to get it to work from a system page. Let you know asap thanks! May 31 '14 at 17:37
  • The rename code doesn't work with 2013. I've been trying to tweak it but to no avail. I've actually lost the ribbon now which is weird. There is an iFrame with the class .ms-dlgFrame, but the title is contained within a child h1 tag. Nothing exists with the ID #dialogTitleSpan either Jun 3 '14 at 21:00
  • @Colbs I tried it on my 2013 online and I can confirm the item #dialogTitleSpan is there
    – MdMazzotti
    Jun 4 '14 at 9:19
  • @Colbs here's a screeshot: s4.postimg.org/bnx16tfb1/ss1.jpg And here's another one where you can see the #dialogTitleSpan exists s29.postimg.org/rnufxij87/ss2.jpg
    – MdMazzotti
    Jun 4 '14 at 9:25
  • Gotcha. Np to change that ID but what about the click event? I don't have an Upload button, only 'new item' Jun 4 '14 at 14:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.