1

I understand that the following URL will give me the thumbnail of a document or the placeholder image, if there isn't a thumbnail. This works because of the ph=true at the end.

http://cms.mydomain.com:8080/share/proxy/alfresco/api/node/workspace/SpacesStore/" + childId + "/content/thumbnails/doclib?ph=true

I have also found that the following server side code will get me the ContentStream of the thumbnail image.

    OperationContext context = session.createOperationContext();
    context.setRenditionFilterString("cmis:thumbnail");
    CmisObject doc = session.getObject(id, context);
    List<Rendition> renditions = doc.getRenditions();
    if (renditions.size() > 0) {
        Rendition rend = renditions.get(0);
        cs = rend.getContentStream();
    }

The problem with this is it does not return the placeholder image if there isn't a thumbnail, like the first URL.

For the server side how would I retrieve the appropriate placeholder image when there isn't a thumbnail? For example for docx and xlsx files.

Thanks, Jon

Jon Mitchell
  • 217
  • 6
  • 16

2 Answers2

3

I think in this case the most effective way to retrieve thumbnails (doclib or a placeholder) is to call directly the REST Alfresco Service.

I'm not 100% sure but CMIS rendition response from an Alfresco Server contains only existing renditions. There's no placeholder provided in CMIS renditions part like the one provided by the Alfresco REST url.

JM.Pascal
  • 281
  • 1
  • 10
  • 1
    Agreed, Jean-Marie. I don't think the placeholder can be fetched via CMIS. – Jeff Potts Feb 02 '13 at 00:56
  • 1
    Hmm. I'm sure I managed to get at doclib thumbnail content (renditions in CMIS terms) using the CMIS Workbench client. Might be worth a check there, although I've never seen it explicitly documented in the API. – Will Abson Feb 02 '13 at 08:53
  • @JM.Pascal Can someone point me in the right direction for the Alfresco REST services? Sounds better than re-inventing the wheel. - Jon – Jon Mitchell Feb 04 '13 at 13:24
  • 1
    Go to http://localhost:8080/alfresco/service/index and sign in with admin/admin. Then click on "Browse by Web Script Package" and go down to /org/alfresco/repository/thumbnail. Click on this and there is a web service for retrieving the thumbnail or placeholder. – Jon Mitchell Feb 05 '13 at 13:28
0

The key here is in if (renditions.size() > 0) -> this is exactly what the webscript does.

But what the REST webscript also does is to ad an else -> so if there aren't renditions so far, it fill determine mimetype and fetch the corresponding placeholder.

You should do the same in your code to make it fetch placeholder -> add an else and then find the placeholder for that image.

Zlatko
  • 18,936
  • 14
  • 70
  • 123
  • That makes sense, but what I do not understand is how to "then find the placeholder for that image." – Jon Mitchell Feb 04 '13 at 13:23
  • Well the same way as the REST javascript controller does - determine the mimetype and give it the absolute path to the default preview. I'm not looking at code now, so I can't tell you exactly what does JS do there, but it shouldn't be difficult. – Zlatko Feb 04 '13 at 14:35