# -*- coding: utf-8 -*-
"""Module providing views for asset storage folder"""
from Products.Five.browser import BrowserView
from plone import api
from plone.app.blob.interfaces import IATBlobImage


class AssetRepositoryView(BrowserView):
    """ Folderish content page default view """

    def contained_items(self, uid):
        stack = api.content.get(UID=uid)
        return stack.restrictedTraverse('@@folderListing')()

    def item_index(self, uid):
        return len(self.contained_items(uid))

    def preview_image(self, uid):
        images = self.contained_items(uid)
        preview = None
        if len(images):
            first_item = images[0].getObject()
            if IATBlobImage.providedBy(first_item):
                preview = first_item
        return preview

# -*- coding: utf-8 -*-
"""Module providing views for asset storage folder"""
from Products.Five.browser import BrowserView
from plone import api
from plone.app.contenttypes.interfaces import IImage

class AssetRepositoryView(BrowserView):
    """ Folderish content page default view """

    def contained_items(self, uid):
        stack = api.content.get(UID=uid)
        return stack.restrictedTraverse('@@folderListing')()

    def item_index(self, uid):
        return len(self.contained_items(uid))

    def preview_image(self, uid):
        images = self.contained_items(uid)
        preview = None
        if len(images):
            first_item = images[0].getObject()
            if IImage.providedBy(first_item):
                preview = first_item
        return preview

Use newer interface for filtering
Use newer interface for filtering

The image provided by `plone.app.contenttypes` does reintroduce the global
IImage identifier lost during the transition to dexterity based types
