Leadimage Portlet

I would like to have the lead image as a portlet, instead of the viewlet.

Have someone already made this?

PS: Would be nice if the lead image viewlet did not render (at all) if the portlet is enabled (without using CSS or Diazo)

OK, so I am making this as part of 'medialog.leadimagesize'.

Since the leadimage is sometimes displayed in viewlets and sometimes in templates, I wonder:

Is it possible from a viewlet or/and a view to check if a certain portlet is present (in this case the leadimage portlet)?

Is there a check that works for 'inherited portlet', 'content type portlet assignment etc' ?


Update (for reference later):
Looks like one needs to loop through all of them.
Note: if you have more portlet managers it will not 'work'.

class NewsItemView(BrowserView):
    """ A browser view """

    def has_portlet(self):
        for column in ["plone.leftcolumn", "plone.rightcolumn"]:
            manager = getUtility(IPortletManager, name=column)
            retriever = getMultiAdapter((self.context, manager), IPortletRetriever)
            portlets = retriever.getPortlets()

            for portlet in portlets:
                if ILeadimagePortlet.providedBy(portlet["assignment"]):
                    return True

        return False

Made it part of medialog.leadimagesize.
Note: there is no update profile yet (uninstall and reinstall).

1 Like

In core Plone where are lead images still hardcoded in the (I assume you mean content type) templates?

There is a lead image viewlet (for 'lead image behavior')
For News Items it is hardcoded.
note: For 'unknown reasons': You can not use the same view for Page and News Item.

If you look at the video, this is what the add on does: It adds a field to change the lead image size.

I have chosen to show both the viewlet and the 'image in the template' for News Items, and hide them with CSS (or Diazo).

That's < Plone 5.1 , Plone.app.contenttype 1.0.X for Plone 5.0 still has it hard coded in the template.

Plone 5.1 has it hard-coded, I think (I think it is hardcoded for every version that is installed with Universal Installer)

Plone Foundation Code of Conduct