Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

How is it possible to get the URL of an image that is stored in a Picture Library using CAML?

Currently, I've made a CAML Query and run it in the U2U CAML Query Builder, and am seeing values like ows_LinkFilename, ows_LinkFilenameNoMenu, and ows_LinkFilename2 -- fields that store the URL of the image. (They contain what I need - image.jpg or image2.gif, etc.) When I implement it and output the value in that field, I get an "Undefined."

Is it even possible to access the URL from just the file itself? Do I need to make one of the required fields in the Picture Library the name of the image? (image.jpg)

Below is a snippet of the jQuery.

var fieldsToRead =     "<ViewFields>" +
                                "<FieldRef Name='ows_LinkFilename' />" +
                                "<FieldRef Name='ID' />" +
                            "</ViewFields>";

        var query = "<Query>" +
                        "<Where>" +
                            "<IsNotNull>" +
                                "<FieldRef Name='ID' />" +
                            "</IsNotNull>" +
                        "</Where>" +
                        "<OrderBy>" +
                        "<FieldRef Name='Display_x0020_Order' Ascending='True' />" +
                        "</OrderBy>" +
                    "</Query>";

         $().SPServices({
                operation: method,
                async: false,
                webURL: rootURL,
                listName: list,
                CAMLViewFields: fieldsToRead,
                  CAMLQuery: query,
                    completefunc: function (xData, Status) {
                        $(xData.responseXML).SPFilterNode("z:row").each(function() {
                            var name = ($(this).attr("ows_LinkFilename"));

                console.log(name);

Thank you so much for your help.

AA

share|improve this question

1 Answer 1

up vote 0 down vote accepted

By using "<FieldRef Name='EncodedAbsUrl' />", and then having var url = ($(this).attr("ows_EncodedAbsUrl")); instead of var name = ($(this).attr("ows_LinkFilename"));, it pulls the whole URL of the image.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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