I'm using the layout-field of tt_content to render textmedia in different ways. I get the images by using FilesProcessor.
tt_content.textmedia = CASE
tt_content.textmedia {
key.field = layout
default < temp.textmedia
# newElement
newElement = FLUIDTEMPLATE
newElement {
file = EXT:.../newElement.html
dataProcessing.10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
dataProcessing.10 {
references {
table = tt_content
fieldName = assets
}
as = images
}
}
}
How can I access the cropVariants?
Arghh…
Simple solution ...
temp.textmedia < tt_content.textmedia
tt_content.textmedia = CASE
tt_content.textmedia {
key.field = layout
default < temp.textmedia
# newElement
newElement < temp.textmedia
newElement {
templateName = MasonryGallery
}
}
Related
Like the title says, I'd like to manage default meta tags with a specific typo3 page.
I figured out the text-fields like
og:description {
data = DB:pages:49:og_description
override {
required = 1
data = field:og_description
}
}
But it won't work with
og:image {
cObject = IMG_RESOURCE
cObject {
file {
import.data = DB:pages:49:og_image
treatIdAsReference = 1
import.listNum = 0
}
}
}
What am I missing?
Thanks
EDIT:
With a little more research and try and error (There is no fileId in page) i got his working
og:image {
attribute = property
stdWrap.cObject = IMG_RESOURCE
stdWrap.cObject {
file {
import.data = DB:pages:156:og_image
import.listNum = 0
}
begin = 0
maxItems = 1
renderObj = TEXT
renderObj {
stdWrap.typolink {
parameter.stdWrap {
cObject = IMG_RESOURCE
cObject {
file {
crop.data = file:current:crop
cropVariant = facebook_variant1
import.data = file:current:uid
}
}
}
returnLast = url
forceAbsoluteUrl = 1
}
required = 1
}
}
}
Its alle fine, BUT: This won't add the URL to the Image. (should be exact the Same)
twitter:image {
attribute = property
stdWrap.cObject = IMG_RESOURCE
stdWrap.cObject {
file {
import.data = DB:pages:156:twitter_image
import.listNum = 0
}
begin = 0
maxItems = 1
renderObj = TEXT
renderObj {
stdWrap.typolink {
parameter.stdWrap {
cObject = IMG_RESOURCE
cObject {
file {
crop.data = file:current:crop
cropVariant = facebook_variant1
import.data = file:current:uid
}
}
}
returnLast = url
forceAbsoluteUrl = 1
}
required = 1
}
}
}
I'm trying to fetch the first existing image in tt_content to be used in Open Graph (og:image) if any images in tt_content.
page.headerData {
1 = COA
1 {
10 = FILES
10 {
references {
table = tt_content
uid.field = uid
fieldName = image
}
renderObj = TEXT
renderObj {
typolink {
parameter.data = file:current:publicUrl
forceAbsoluteUrl = 1
returnLast = url
}
wrap = |,
}
stdWrap {
listNum = 0
# Use logo image if none is available
ifEmpty.cObject = TEXT
ifEmpty.cObject.typolink {
parameter = typo3conf/ext/my_ext/Resources/Public/Images/logo.png
forceAbsoluteUrl = 1
returnLast = url
}
wrap = <meta property="og:image" content="|">
}
}
}
}
The code above only returns the fallback (logo). Great for pages and tt_content without images, but I would expect different from pages with image(s) in tt_content.
I report here the nice snippet found on https://docs.typo3.org/m/typo3/docs-snippets/master/en-us/2014/Index.html#add-facebook-open-graph-og-image-metatags-for-content-elements-with-typo3-6-0-and-fal
I simplified it a bit; hope it is not too much simplified but it should work:
page.headerData.200 = CONTENT
page.headerData.200 {
table = tt_content
select {
where = {#colPos}=0
selectFields = uid
}
renderObj = FILES
renderObj {
references {
table = tt_content
uid.field = uid
fieldName = image
}
maxItems = 1
renderObj = TEXT
renderObj {
data = file:current:publicUrl
stdWrap {
wrap = <meta name="og:image" content="|" >
}
}
}
}
Here is #riccardo-de-contardi's snippet with a fallback
page.headerData.1569221029 = CONTENT
page.headerData.1569221029 {
table = tt_content
select {
where = {#colPos}=0
selectFields = uid
}
renderObj = FILES
renderObj {
references {
table = tt_content
uid.field = uid
fieldName = image
}
maxItems = 1
renderObj = TEXT
renderObj {
data = file:current:publicUrl
stdWrap {
wrap = |,
}
}
}
stdWrap {
listNum = 0
# Use logo image if none is available
ifEmpty.cObject = TEXT
ifEmpty.cObject.typolink {
parameter = typo3conf/ext/my_ext/Resources/Public/Images/logo.png
forceAbsoluteUrl = 1
returnLast = url
}
wrap = <meta property="og:image" content="|">
}
}
I get the images for a slider via data = level media:-1,slide
On a news-single-page I want to use the news-images instead of. So I put the code for this in conditions [globalVar = GP:tx_news_pi1|news > 0] and get the images of the news. All ok. But I want to show the level media, if there is no news-image. How can I do this?
Here’s the TypoScript:
lib.keyVisual = COA
lib.keyVisual {
10 = FILES
10 {
references {
data = levelmedia:-1,slide
}
renderObj = COA
renderObj.10 = IMAGE
renderObj.10 {
file {
import.data = file:current:uid
treatIdAsReference = 1
width = {$keyVisualWidth}
#width.field >
height = {$keyVisualHeight}
}
}
renderObj.20 = COA
renderObj.20 {
1 = TEXT
1 {
data = file:current:title
required = 1
wrap = <h3>|</h3>
}
2 = TEXT
2 {
data = file:current:description
required = 1
wrap = <p>|</p>
}
stdWrap.wrap = <div class="imageCaptionBox">|</div>
stdWrap.required = 1
}
renderObj.wrap = <li>|</li>
}
wrap = <section id="keyvisual" class="keyvisual fullWidth"><ul class="slider nav">|</ul></section>
}
[globalVar = GP:tx_news_pi1|news > 0]
lib.keyVisual {
10 {
references {
data >
table = tx_news_domain_model_news
uid.data = GP:tx_news_pi1|news
fieldName = fal_media
}
# only images with showinpreview
renderObj.if {
value = 1
equals.data = file:current:showinpreview
}
}
}
[global]
Work with the ifEmpty stdWrap option.
If your COA is empty you can render the default image with this option.
simple example to explain:
[globalVar = GP:tx_news_pi1|news > 0]
lib.keyVisual {
stdWrap.ifEmpty.cObject < .10
#overrides for news picture
10 {
...
}
}
[global]
all conditions have an [else] so you do not need to redefine.
[globalVar = GP:tx_news_pi1|news > 0]
lib.keyVisual {
... from news...
}
[else]
lib.keyVisual {
... from levelmedia ...
}
[global]
then you need to distinguish wether an image is availabel for the news.
[globalVar = GP:tx_news_pi1|news > 0]
lib.keyVisual = COA
lib.keyVisual {
10 = CONTENT
10 {
// get news record and then get file
... from news...
if.empty.field = media
}
20 = FILES
20 {
... from levelmedia ...
if {
empty.field = media
negate = 1
}
}
}
[else]
lib.keyVisual {
... from levelmedia ...
}
[global]
that could be optimized by using a temp object for the levelmedia usage which gets copied.
temp.levelmediaImage {
...
}
[globalVar = GP:tx_news_pi1|news > 0]
kib.keyVisual = COA
lib.keyVisual {
10 = CONTENT
10 {
// get news record and then get file
... from news...
if.empty.field = media
}
20 < temp.levelmediaImage
20 {
if {
empty.field = media
negate = 1
}
}
}
[else]
lib.keyVisual < temp.levelmediaImage
[global]
I need help with image processing configuration in Typo3 7.6.4. All images are being processed no matter how big they are. That causes that the images are not in original size and unsharp, renamed and copied in processed folder. I would like to configure image processing so that it is activated only if images have some specific size (px or kb/mb). For example if image have more than 1MB or if the is width more than 800px, than processed it otherwise leave it as it is and link to original file (no copy, no processing). Thanks
page.10 = FLUIDTEMPLATE
page.10 {
template = CASE
template {
key.data = levelfield:-1,backend_layout_next_level,slide
key.override.field = backend_layout
1 = FILE
1.file = fileadmin/templates/sitename/main_1_column.html
2 = FILE
2.file = fileadmin/templates/sitename/main_2_column.html
}
partialRootPath = fileadmin/templates/sitename/partials/
layoutRootPath = fileadmin/templates/sitename/layouts/
variables {
siteName = TEXT
siteName.value = sitename
header < styles.content.get
header.select.where = colPos = 0
contentMain < styles.content.get
contentMain.select.where = colPos = 1
content_column_1 < styles.content.get
content_column_1.select.where = colPos = 1
content_column_2 < styles.content.get
content_column_2.select.where = colPos = 2
footer < styles.content.get
footer.select.where = colPos = 3
}
}
tt_content {
stdWrap {
innerWrap {
cObject {
default.20.40 = CASE
default.20.40 {
key.field = layout
default = TEXT
default.value = img-responsive
}
}
}
innerWrap2 >
}
image {
20 {
1 {
params.cObject = TEXT
params.cObject {
wrap = class="|"
cObject < tt_content.stdWrap.innerWrap.cObject.default.20.40
}
sourceCollection >
sourceCollection {
big {
maxW = 5000
dataKey = big
}
small {
maxW = 500
dataKey = small
}
smallLandscape {
maxW = 800
dataKey = smallLandscape
}
}
}
maxW = 5000
}
}
}
In a COA, I have this TypoScript to add an image linked to a larger copy of itself. But the Javascript plugin I'm using (Colorbox) isn't able to resize the image properly.
20 = CONTENT
20 {
wrap = <div class="lightbox clearfix">|</div>
required = 1
table = tt_content
select.languageField = sys_language_uid
select.where = colPos = 2
select.selectFields = bodytext,image,header
renderObj=COA
renderObj{
10 = FILES
10 {
required = 1
references {
table = tt_content
fieldName = image
}
renderObj = IMAGE
renderObj {
file.import.data = file:current:originalUid // file:current:uid
file.width=300c
file.height=300c
imageLinkWrap = 1
imageLinkWrap {
enable = 1
width = 1600m
height = 1600m
JSwindow = 0
linkParams.ATagParams {
// title.data =
dataWrap = class = "lightbox-group" title="{file:current:description}"
}
}
}
}
}
}
What's up?
Here's the correct TypoScript. I'm sharing it because it is a legacy weirdness others might stumble upon too.
You have to set imageLinkWrap.directImageLink = 1, else imageLinkWrap won't deliver the image itself, but a HTML page containing that image!
20 = CONTENT
20 {
wrap = <div class="lightbox clearfix">|</div>
required = 1
table = tt_content
select.languageField = sys_language_uid
select.where = colPos = 2
select.selectFields = bodytext,image,header
renderObj=COA
renderObj{
10 = FILES
10 {
required = 1
references {
table = tt_content
fieldName = image
}
renderObj = IMAGE
renderObj {
file.import.data = file:current:originalUid // file:current:uid
file.width=300c
file.height=300c
imageLinkWrap = 1
imageLinkWrap {
enable = 1
width = 1600m
height = 1600m
directImageLink = 1
JSwindow = 0
linkParams.ATagParams {
// title.data =
dataWrap = class = "lightbox-group" title="{file:current:description}"
}
}
}
}
}
}