0

I have a jQuery to display pictures as thumbnail for a document library. It works great but as soon as I add grouping to the view then the pictures do not show up as thumbnail. They show up with traditional file type icons (icjpg.gif, icpng.gif, etc.). Any idea how to fix this?

<SCRIPT type=text/javascript>
$(document).ready(function(){
$("img[src$='icjpg.gif'], img[src$='icpng.gif']").each(SetImage)
});
function SetImage()
{
    $(this).attr('height','100');
    $(this).attr('src','/it/Site/DocLib/'+$(this).attr('title')); 
}
</SCRIPT>
1
  • I tried this but the test alert don't fire. $("td.ms-gb").each(function(){ alert('line 10'); //$("img[src$='icjpg.gif'], img[src$='icpng.gif']").each(SetImage); alert('line 11'); } });
    – Jason Baig
    Feb 25 '15 at 17:53
1

I may not fully understand what you are trying to achieve.

You want to display a 100x100 thumbnail of the Image in a Document Library and the image name is in the Title field?

You can achieve this with a Calculated Column (set to datatype=Number):

="<IMG height=""100px"" width= ""100px"" src="""
&[Title]
&""">"

datatype Number wil be output as HTML

0

After following this (Run JavaScript after "group by" in list has been clicked on and list data loaded) article I was able to get the following code working.

<script type="text/JavaScript" src="/_layouts/jquery/jquery-1.11.0.min.js"></script>
<SCRIPT type=text/javascript>
$(document).ready(function(){
var oldExpand = ProcessImn;
ProcessImn = function(){
    var results = oldExpand.apply(this, arguments);
    $("img[src$='icjpg.gif'], img[src$='icpng.gif']").each(SetImage);
    return results;
    }
});

function SetImage()
{
    //alert('line 15');
    $(this).attr('height','100');   
    //alert('line 17');
    $(this).attr('src','/it/Site/DocLib/'+$(this).attr('title'));   
}

</SCRIPT>

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.