Domanda

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

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top