I have a picture library in SharePoint 2016 with the ratings enabled. I want users to be able to rate each picture in the library. In the display view, just the image icon shows and not the actual picture.

Users would have to click the icon to see the image and then hit the back button to rate the image. I want to show the image on the view so that there will be no drill down to see the picture. I created the below JS link to convert the icon to the image but I get an error that makes no sense.

The error I get in the console shows:

SCRIPT1006: Expected ')'

(funciton() {
    var nameFieldContext = {};
        nameFieldContext.Templates = {};
        nameFieldContext.Templates.Fields = {
            "Name": {"View": renderImageToRate }
})();  //<---- error points to this line

function renderImageToRate(ctx){
alert("In function");
    var name = ctx.CurrentItem.Name;
    return "<img src='../pictureLib/'"+name+">";

The code looks fine to me. Any ideas?


Your code looks fine to me as well. But I noted there is small syntax error in your code in 1st line.

You misspelled the function keyword. Try correcting it.

  • 1
    Thank you! It's always good to have a 2nd set of eyes
    – OLA
    Dec 10 '20 at 13:27

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.