How to choose an image from Neos Media in a newly created module

Hey , I started recently with Neos , I created a simple new backend module for teasers , in that module the user could add teaser title and image for that teaser , for now I could only add the full URL for the Image to be able to show it , what is what to learn is :

How to add Image onClick input that shows (when pressing on it) the Media Library and let the user choose which image he wants to use in this teaser and persist the image ID in the teaser table and then to be able to show it ?

This image explains what I want simply :

Thank you

Hi @khatib_a,

might i ask why you created a backend module? Wouldn’t a new NodeType fit also?

Second the question of @stolle.

However it is possible by doing it the same way it’s done for the image editor in the inspector.

Basically you write some JavaScript that creates an iframe when clicking the button and provide callbacks that the iframe triggers.

Link is either (images only) or, example of generating those links.

Example of callbacks

Be aware that this is not official API and you code might break in future versions.

because I want to use it in different other enterprise solutions so I want it as standalone module , if it’s NodeType what would be the solution for such issue ?

Thanks for the question @stolle :smile:

Thanks @aertmann , I did not understand is that a URL that I can use inside another module ?

<link rel="neos-image-browser" href="{f:uri.action(action: 'index', controller: 'Backend\ImageBrowser', package: 'TYPO3.Neos', absolute: true, arguments: {assetCollection: node.context.currentSite.assetCollection})}" />

We’ll you could just create a NodeType, add/edit your content within Neos. And if you need to access the data from another application you can easily create a Json-API or anything else that your application can read. You can use withing php the FlowQuery Class, fetch your nodes and stuff and return all data you need to.
That’s one big advantage of neos. You can use neos as a content repository. You don’t even have to run the website itself with neos, but you can easily create and edit content within Neos and stream it to some other applications.

1 Like

Sorta, it’s how to get the link needed for the iframe.

<iframe src="{f:uri.action(action: 'index', controller: 'Backend\ImageBrowser', package: 'TYPO3.Neos', absolute: true, useParentRequest: TRUE)}" />
1 Like