Silvio Habel
Silvio Habel

Reputation: 1

TYPO3 tt_content --> image

I've following code in my TypoScript:

MAINCONTENT = COA
MAINCONTENT.10 = CONTENT
MAINCONTENT.10{
    table=tt_content
    #select.where = uid=5
    select.pidInList = 33
    renderObj = COA
    renderObj {
        10=TEXT
        10.value = <div class="news">

        20=IMAGE
            20{
                required=1
                file.import=fileadmin/images/
                file.import.field=image
                file.width=170
                file.height=100
            }
        20.wrap = <div class="news_image">|</div><div class="news_content">

        30=TEXT
        30.field=crdate
        30.date = d.m.Y
        30.wrap=<div class="news_content"><div class="news_datum"> | </div>

        40=TEXT
        40.value=<div class="news_rubrik"><strong>Rubrik:</strong> testrubrik</div>

        #stdWrap.outerWrap = <div id="article">|</div>
        50=TEXT
        50.field = header
        50.wrap=<div class="news_headline"><a> | </a></div>

        60=TEXT
        60.field=bodytext
        60.wrap=<div id="content_text"> | </div></div><div class="cf"></div></div><div class="newstrenner"></div-->

        70=TEXT
        70.value = </div>
    }
}

My question is about the 20 - IMAGE Object.

How can i get the image - which is uploaded by an editor - from the tt_content ?

Is the tt_content maybe the wrong table ?

Upvotes: 0

Views: 3041

Answers (1)

lorenz
lorenz

Reputation: 4558

Welcome to TYPO3 :-). If you want to do TYPO3 a favor, spell it as I spelled it 8 words ago :-). As for your code, it's going to the right direction. I assume you're using TYPO3 4.x since quite some things changed in image handling with TYPO3 6.0 (and the introduction of the File Abstraction Layer).

For getting the first image of the content, you can use the following code:

20 = IMAGE
20 {
  required=1
  file.import = uploads/pics/
  file.import.field = image
  file.import.listNum = 0
  file.width=170
  file.height=100
}

Since all pictures attached to a content element are copied to uploads/pics in TYPO3 4.x, you must indicate this path.

listNum = 0 tells TYPO3 to take the first picture. A tt_content can hold multiple images that are stored comma-separated in the database.

Upvotes: 3

Related Questions