Hi,
I have been trying the whole day to get image renditions collection from my publishing site using the javascript API. To be noted, I am developping for SP2013 on O365.
I found I had to load sp.publishing.js, and then call :
SP.Publishing.SiteImageRenditions.getRenditions(context)
So, I did the following :
var clientContext = new SP.ClientContext.get_current();
this.rend = SP.Publishing.SiteImageRenditions.getRenditions(clientContext)
clientContext.executeQueryAsync(
Function.createDelegate(this, this.onQuerySucceeded),
Function.createDelegate(this, this.onQueryFailed)
);
function onQuerySucceeded() {
var result = this.rend;
console.log(result);
}
function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() +
'\n' + args.get_stackTrace());
}The query succeeded but all I got is an array (same size than the current number of renditions, at leastthis is correct..) but, all the SP.Publishing.ImageRendition in that array seem not initiated to me. All properties are 0 or null-valued.
Interesting fact thought : in firebug I can track the result of the XRH underlying query (sent to https://server/site/_vti_bin/client.svc/ProcessQuery) and the response of this query is the very JSON object containing the result that I'm looking for (the array of renditions, initialized with the correct IDs, heights, widths and everything).
PS: a lot of documentation on the internet (including MSDN) still mentions that the REST publishing API can be calledvia /_api/publishing. But each time I try to call that URL I get an error from SP
<m:error><m:code>
-1, Microsoft.SharePoint.Client.ResourceNotFoundException</m:code><m:message xml:lang="en-US">
Cannot find resource for the request publishing.</m:message></m:error>Does it make any sense for anyone :) ?