Image processing configuration - typo3

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
}
}
}

Related

Use a specific typo3 page for default meta tags

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
}
}
}

Override FILES references.data with fallback

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]

Fallback image in typoscript

I have the following menu-type, which works correctly for the main-part.
However, i want to add a fallback image, if no image is found.
tt_content.menu {
20 {
108 = HMENU
108 {
special = directory
special.value.field = pages
1 = TMENU
1.wrap = <div class="special_menu">|</div>
1.NO {
doNotLinkIt = 1
stdWrap.cObject = COA
stdWrap.cObject {
10 = FILES
10 {
references {
table = pages
fieldName = media
}
renderObj = IMAGE
renderObj {
file {
width = 263c
height = 155c
maxW = 263c
maxH = 155c
import.data = file:current:publicUrl
# if file:current:publicUrl is empty, use default image
if.isFalse = fileadmin/my/path/to/image.jpg
}
altText.field = title
imageLinkWrap = 1
imageLinkWrap {
enable = 1
typolink.parameter.field = uid
}
}
stdWrap.wrap = <div class="menu10_bild">|</div>
}
20 = TEXT
20.field = title
20.typolink.parameter.field = uid
20.wrap = <div class="menu10_text">|
30 = TEXT
30.field = abstract
30.wrap = <p>|</p></div><div class="w-clearfix"> </div>
}
}
}
}
}
for some reason, it just ignores the line. Can someone help me with that?
You should check the TypoScript Reference stdWrap.ifEmpty.
In your case the code should look like this
tt_content.menu {
20 {
108 {
1.NO {
stdWrap.cObject {
10 = FILES
10 {
# ....
stdWrap.ifEmpty.cObject = IMAGE
stdWrap.ifEmpty.cObject{
file = fileadmin/.../my_image.png
}
# ....
}
}
}
}
}
}
You can use every cObject you want.
Check out Content Objects (cObject)
Try this:
tt_content.menu {
20 {
108 = HMENU
108 {
special = directory
special.value.field = pages
1 = TMENU
1.wrap = <div class="special_menu">|</div>
1.NO {
doNotLinkIt = 1
stdWrap.cObject = COA
stdWrap.cObject {
# default image
value = fileadmin/my/path/to/image.jpg
10 = FILES
10 {
references {
table = pages
fieldName = media
}
renderObj = IMAGE
renderObj {
file {
width = 263c
height = 155c
maxW = 263c
maxH = 155c
import.data = file:current:publicUrl
}
altText.field = title
imageLinkWrap = 1
imageLinkWrap {
enable = 1
typolink.parameter.field = uid
}
}
stdWrap.wrap = <div class="menu10_bild">|</div>
}
20 = TEXT
20.field = title
20.typolink.parameter.field = uid
20.wrap = <div class="menu10_text">|
30 = TEXT
30.field = abstract
30.wrap = <p>|</p></div><div class="w-clearfix"> </div>
}
}
}
}
}

My manually built TYPO3 lightbox isn't working properly

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}"
}
}
}
}
}
}

tt_news category image url

I need the url of the image from tt_news category to fill conf.tt_news.10.stdWrap.ifEmpty. Does anyone have an idea. My approach
lib.catimage = TEXT
lib.catimage {
table = tt_news_cat
select {
pidInList = 2
andWhere {
data = GPVar:tx_ttnews|cat
....????
page.headerData {
15 = RECORDS
15 {
source.data = GPvar:tx_ttnews|tt_news
tables = tt_news
conf.tt_news = COA
conf.tt_news.10 = IMG_RESOURCE
conf.tt_news.10.file {
width = 403
import = uploads/pics/
import.field = image
import.listNum = 0
}
conf.tt_news.10.stdWrap.ifEmpty < lib.catimage
wrap = <link rel="image_src" href="{$BaseUrl}|" />
}
}
I have a new approach, but do not see the error. If I take out the commented brace the path is correct but the syntax of the script is incorrect. The first part also does not work anymore. Here the modified version.
page.headerData {
15 = RECORDS
15 {
source.data = GPvar:tx_ttnews|tt_news
tables = tt_news
conf.tt_news = COA
conf.tt_news.10 = IMG_RESOURCE
conf.tt_news.10.file {
width = 403
import = uploads/pics/
import.field = image
import.listNum = 0
}
conf.tt_news.10.stdWrap.ifEmpty.cObject = CONTENT
conf.tt_news.10.stdWrap.ifEmpty.cObject {
table = tt_news_cat
select {
selectFields = image
pidInList = 2
languageField = sys_language_uid
where = deleted=0 AND hidden=0
andWhere {
data = GPvar:tx_ttnews|category
wrap = uid=|
intval = 1
}
}
#}
renderObj = TEXT
renderObj.field = image
}
wrap = <link rel="image_src" href="{$BaseUrl}|" />
}
}