I created two fields in templavoila and want to access the image url (data object) from the other field.
field1 - typoscript - type: image:
10 = IMG_RESOURCE
10.file.import = uploads/tx_templavoila/
10.file.import.current = 1
10.file.import.listNum = 0
10.file.maxH = 300
field2 - typoscript:
10 = IMG_RESOURCE
10.file.import.data = field1
But id doesn't work. I tried various variations of the above, but nothing works :(
Any help would be appreciated!
Thanks,
Mark.
The object should be IMAGE type instead of IMG_RESOURCE.
And on the field2 typoscript:
10 = IMAGE
10.file.import.field = field1
10.file.import = uploads/tx_templavoila/
10.file.import.listNum = 0
10.file.maxH = 300
This should display the image uploaded on the field type image "field1".
Hope this helps!
Cornelia
Related
I want to use the GIFBUILDER to make an image with an overlay. The image should therefore be delivered via FLUID.
This is what I have so far:
FLUID
<f:for each="{product.images}" as="image">
<f:cObject typoscriptObjectPath="lib.overlay" data="{image: image.uid}" />
</f:for>
TypoScript
lib.overlay = IMAGE
lib.overlay {
file = GIFBUILDER
file {
XY = 300,500
format = jpg
quality = 80
10 = IMAGE
10 {
file.import = {field:image}
file.import.insertData = 1
file.import.treatReferenceAsId = 1
}
20 = TEXT
20 {
text = Copyright
fontColor= #dddddd
fontSize = 30
offset = 100,100
align = left
antiAlias = 1
}
}
}
At the moment, I only get a white Background with the label Copyright on it. However if I do somethinge like
10 = IMAGE
10.file = fileadmin/path/to/file
all works just fine.
So my question is: How do I pass the Image from FLUID correctly to TypoScript?
And as addition to this, how do I pass a value from the Contentelement via FLUID to make the overlay text dynamic too?
Best regards and Thanks in advance
UPDATE:
output of {image} (one image):
Replace
10 = IMAGE
10 {
file.import = {field:image}
file.import.insertData = 1
file.import.treatReferenceAsId = 1
}
with
10 = IMAGE
10 {
file.import.field = image
file.treatIdAsReference = 1
}
treatReferenceAsId should be treatIdAsReference. It's also a property of file, not of file.import. I'm not sure why file.import = {field:image} and insertData = 1 doesn't work, but file.import.field = image does. It's cleaner anyway, which is why I tried it.
You might also want to add a width and height or maxW and maxH to the image, unless you're 100% sure they're always 300x500 pixels.
i want to write a Copyright-Entry on images which are created with GifBuilder:
lib.imageWithWatermark = IMG_RESOURCE
lib.imageWithWatermark {
file = GIFBUILDER
file {
XY = [10.w],[10.h]
format = jpg
quality = 100
10 = IMAGE
10.file {
import.data = current
treatIdAsReference = 1
maxW = 1600
maxH = 1000
}
20 = IMAGE
20.offset = [10.w]-[20.w]-20,[10.h]-[20.h]-20
20.file = fileadmin/theme/lib/v1/img/watermark.png
30 = TEXT
30 {
text = Copyright
fontColor= #dddddd
fontSize = 12
offset = 20,[10.h]-20
fontFile = fileadmin/theme/lib/v1/fonts/verdana.ttf
align = left
antiAlias = 1
}
}
}
in 30.text I need the entry from the meta data of the image (image.resources.properties.creator in fluid) but i dont have any clue how to achieve this in typoscript ...
Any help?
Thanks!
OK, after a few hours I found the solution. Perhaps it is useful for some other people ... :-)
lib.imageWithWatermark = COA
lib.imageWithWatermark {
# get meta data here - in GIFBUILDER it seems not possible
10 = FILES
10 {
# current derives from a fluid template: it contains the uid of a sys_file_reference entry (!) - not sys_file
# so we cannot use files but must use references which links sys_file_reference with sys_file.
references.data = current
renderObj = COA
renderObj {
# we have to use register
10 = LOAD_REGISTER
10 {
param = TEXT
# Attention: current is now the current file in renderObj - it contains now the uid of the sys_file entry.
param.data = file:current:creator
}
}
}
# OK the more tradional rest
20 = IMG_RESOURCE
20 {
file = GIFBUILDER
file {
XY = [10.w],[10.h]
format = jpg
quality = 100
10 = IMAGE
10.file {
import.data = current
treatIdAsReference = 1
maxW = 1600
maxH = 1000
}
20 = IMAGE
20.offset = [10.w]-[20.w]-20,[10.h]-[20.h]-20
20.file = fileadmin/theme/lib/v1/img/watermark.png
30 = TEXT
30 {
# get text from register.
text.data = register:param
fontColor= #dddddd
fontSize = 12
offset = 20,[10.h]-20
fontFile = fileadmin/theme/lib/v1/fonts/verdana.ttf
align = left
antiAlias = 1
}
}
}
}
At current I'm making a list of images for a banner slider using code as follows:
page.10.marks.topimage = IMAGE
page.10.marks.topimage {
file.import.data = levelmedia: -1, "slide"
file.import = fileadmin/user_upload/
file.import.override.field = media
file.import.current = 1
file.import.listNum = 0
border = 0
file.height = 670
file.width = 1800
altText = Banner
titleText = Banner
wrap = <div id="slides">|
}
page.10.marks.topimage1 = IMAGE
page.10.marks.topimage1 {
file.import.data = levelmedia: -1, "slide"
file.import = fileadmin/user_upload/
file.import.override.field = media
file.import.current = 1
file.import.listNum = 1
border = 0
file.height = 670
file.width = 1800
altText = Banner
titleText = Banner
}
etc...
However, this means, every time the other admins want to add a new slide or remove one from the total count, I have to change this code. Adding the content of the slides is not a problem, they simply upload to user_upload and it pulls 0 to 3 at current. However, they want to be able to upload 5 images and have it show 5 or just 3 and have it show 3 and I need a more dynamic way to implement this. I'm still new to Typo3 (i really don't understand it, php is 10,000X easier!), so if anyone could, please explain to me better than the docs, how subparts work or what my solution might be.
And no I can't just write an extension to do it. Been there and tried that and still can't figure out how to get extensions in without breaking it.
FYI, if you could break it down and help me "like" it, that would be great, because at current, I'd rather they use wordpress or joomla or ANYTHING but this. If you've seen my other questions, then you'll realize, i've had 0 fun working with this cms and mostly because the documentation and/or "help" i've received has been almost completely useless to me. I only mention this so that maybe someone will break this down for me like i break down jquery/php/.net questions for others. It doesn't hurt to be polite and show a nub "step-by-step" instructions!
page.10.marks.topimage = TEXT
page.10.marks.topimage {
# retrieve data
data = levelmedia: -1, "slide"
override.field = media
# we have some filenames in a list, let us split the list
# and create images one by one
# if there are five images selected, the CARRAY "1" will be executed
# five times where current is loaded with only one filename
split {
# the images are separated via ","
token = ,
# you can do funny stuff with options split, f.e. if you want to give first
# and last image a different class... but thats another topic;)
# we just say, render every splitted object via CARRAY "1"
cObjNum = 1
1 {
# just render the single image,
# now there should be one filename in current only
10 = IMAGE
10 {
file.import.wrap = fileadmin/user_upload/|
file.import.current = 1
border = 0
file.height = 670
file.width = 1800
altText = Banner
titleText = Banner
}
}
}
}
So lets say I have something like this:
20 = CONTENT
20{
table = tt_content
select{
pidInList = 1
where = colPos = 0
}
renderObj = COA
renderObj{
wrap = <div class="normal">|</div>
10 = TEXT
10{
field = bodytext
}
}
}
and I want that every third object changes the class "normal" by "special". How could I do such operation in Typoscript?
Use optionSplit (DE) for this task on the wrap value, you need abcabc pattern where a,b = normal, c = special, so most probably it will be something like this:
wrap = a||b||c |*| a||b||c
Wrote it from top of my head so you need to check it.
I have made a plugin where I store many images in the "media" field and jsut as many captions in the field "imagecaption".
Now my wish is to display it like this:
image1.png
caption 1
image2.png
caption 2
image3.png
caption 3
This is how ive been trying to do it, but its not working:
plugin.tx_myplugin_pi1 = COA
plugin.tx_myplugin_pi1{
10 = TEXT
10.field = header
10.wrap = <h1>|</h1>
20 = COA
20{
10 = TEXT
10{
field = media
split{
token = ,
cObjNum = 1
1.current = 1
}
}
20 = TEXT
20{
field = imagecaption
split{
token.char = 10
cObjNum = 1
1.current = 1
}
}
}
}
But its not really working, as it shows first all the filenames and then the caption.
How could I do it?
Split is a function which returns all elements. Within 20.10 you get the content of field image, splitted by an newline f.e. and after that, you get the content of 20.20 which has the imagecaption.
What you need to do (untested):
10 = TEXT
10{
field = media
split{
token = ,
cObjNum = 1
1.current = 1
# for each image, add the imagecaption
1.append = TEXT
1.append {
field = imagecaption
# split saves the index in REGISTER:SPLIT_COUNT
listNum.stdWrap.data = REGISTER:SPLIT_COUNT
listNum.splitChar = 10
}
}
}
I do not think that token = \n is correct. You properly need to use .char = 10.
Also you will need to nest your TS somehow, because the current solution does handle the fields one by one.
I can't remember at the moment but I've wrote an extension that adds a frame to a picture and caption. It can solve your problem with the captions: http://typo3.org/extensions/repository/view/ch_imgtext_renderengine/current/.