[TYPO3-dev] Media Column in Database changed

Philipp Gampe philipp.gampe at typo3.org
Mon Nov 23 19:55:09 CET 2015


Hi NGUYEN Duc Quan,

NGUYEN Duc Quan wrote:

> In the pages table (in v4.7) the media columns had the filename which had
> been selected in the "Resources" tab under "Files" -> "Media". Now in v7.6
> the value of the media column is 0 or 1. I assume that 1 means there has
> been an media file attached to the page.

The field is now a relation to the sys_file_reference table. Therefore the 
field contains the count of relations now. This is clever, because you can 
easily check if there are relations at all and how many there are.

> My current task/issue is to retrieve the image file associated to the
> page. As the (direct) reference in not saved anymore in the media column
> the information has to be somewhere else since in the BE I can see the
> associated resource (image).

With TypoScript this is easy, the updated documentation (TypoScript 
Reference) contains examples on how to retrieve files.

> I am updating an extension which reads the image file from the resources
> of a page in PHP.

This is slightly more tricky, but not much.

> Could somehow help me by providing a code snippet or give me a push in the
> right direction to solve this issue?

You can use the method findByRelation() from the 
\TYPO3\CMS\Core\Resource\FileRepository.

Best regards
-- 
Philipp Gampe – PGP-Key 0AD96065 – TYPO3 UG Bonn/Köln
Certified Integrator – Active contributor TYPO3 CMS
TYPO3 .... inspiring people to share!




More information about the TYPO3-dev mailing list