Using the TYPO3 crop function for cs_seo social media images - typo3

I am using TYPO3 7LTS with Ext:cs_seo and want to crop the social media images. Unfortunately my approach via file:current:crop doesn't work:
page.meta {
twitter:image.stdWrap.typolink {
parameter.stdWrap {
cObject.file >
cObject.file {
import {
preUserFunc = Clickstorm\CsSeo\UserFunc\HeaderData->getSocialMediaImage
preUserFunc.field = twitter_image
ifEmpty.data = path:{$plugin.tx_csseo.social.twitter.defaultImage} // path:{$plugin.tx_csseo.social.defaultImage}
}
crop.data = file:current:crop
height < plugin.tx_csseo.social.twitter.image.height
width < plugin.tx_csseo.social.twitter.image.width
}
}
}
og:image.stdWrap.typolink {
parameter.stdWrap {
cObject.file >
cObject.file {
import {
preUserFunc = Clickstorm\CsSeo\UserFunc\HeaderData->getSocialMediaImage
preUserFunc.field = og_image
ifEmpty.data = path:{$plugin.tx_csseo.social.defaultImage}
}
crop.data = file:current:crop
height = {$plugin.tx_csseo.social.openGraph.image.height}
width = {$plugin.tx_csseo.social.openGraph.image.width}
}
}
}
}
Has somebody a clue, how I can fix it?
Thank you in advance
Bertram

You should either get rid of the line that removes the file settings completely and disable the settings within the file section.
So the bad line IMHO should be:
cObject.file >
Since this destroys the rest of the setup.

Related

Unity ScrollViewScope horizontal scroll not working with EditorGUILayout

I need to use EditorGUI.IndentLevelScope and it only work with EditorGUILayout like LabelField, Foldout, not in GUILayout like Label.
here is my code
using (var midScroll = new EditorGUILayout.ScrollViewScope(midSPos, true, true))
{
using (new EditorGUI.IndentLevelScope(1))
{
midSPos = midScroll.scrollPosition;
for (int i = 0; i < 50; i++)
{
EditorGUILayout.LabelField("This is a EditorGUILayout.LabelField. This is a EditorGUILayout.LabelField.", GUI.skin.GetStyle("LinkLabel"));
}
}
}
Vertical work but not Horizontal
Pic: https://gyazo.com/70382d83222dc7fc2db54c4745836dfc
same code with GUILayout.Label work both
what do i miss
End up I found a solution for Label by adding an empty PrefixLabel in front and back to GUILayout again, the scroll now works.
HorizontalScope
EditorGUILayout.PrefixLabel("");
GUILayout.Label("content");
But still, have some issues with my foldout like this since I can't add HorizontalScope to it.
InitRow(row row)
{
if (isShowing = EditorGUILayout.Foldout(isShowing, "Foldout"))
{
InitRow(child);
}
}

Typo3 Gridelements - setup not working

I'm using Typo3 7.6.10 with Gridelements 7.0.5. I'm trying to wrap the gridelement output with the following code but the wrapping is not working. Both files are loaded. The 2-cols-50-50 element is available in the backend and the static gridelements template is loaded. The content of the gridelement is displayed without the wrap defined in the gridelements.ts file.
I would be happy for every help.
tsconfig.ts
tx_gridelements {
overruleRecords = 1
setup {
2-cols-50-50 {
title = 2-Columns
description = 2-columns contentelement
topLevelLayout = 0
config {
colCount = 2
rowCount = 1
rows {
1 {
columns {
1 {
name = Left
colPos = 11
}
2 {
name = Right
colPos = 12
}
}
}
}
}
}
}
}
gridelements.ts
tt_content.gridelements_pi1.20.10.setup >
tt_content.gridelements_pi1.20.10.setup {
2-cols-50-50 < lib.gridelements.defaultGridSetup
2-cols-50-50 {
columns {
11 < .default
11.wrap = <div class="left">|</div>
12 < .default
12.wrap = <div class="right">|</div>
}
wrap = <div class="well">|</div>
}
}
I found the mistake. The static gridelements template has to be included before the extension template. Otherwise the static template overwrites tt_content.gridelements_pi1.

How to use lib.* Variables the correct way in TypoScript

this is my first submission.
I want a specific image as Background in my Typo3 Template. I want to parse the needed Image from a reference in the Page. Below Code I copied from another website and it seems correct.
lib.headerimage = IMAGE
lib.headerimage {
file {
import.data = levelmedia:-1, slide
treatIdAsReference = 1
import.listNum = 0
}}
The Problem now is, I want the lib.headerimage.FILELINK to be in my following code and I can't figure out how to use lib.VARIABLES
In a later point I parse this:
page.headerData {
10 = TEXT
10.value = div#header { background-image: url('lib.headerimage.file.value');}
10.wrap = <style type="text/css">|</style>
}
With our without $ it doesn't parse anything. I just started using typoscript 3 days ago again. My last experiences were years back.
Please , there must be an easy way to do this. :/
It looks like you search a way to concat strings. Assumed the first part is correct (As I am not familiar with the IMAGE Object) you can concat the strings like this:
page.headerData {
10 = COA
10 {
10 = TEXT
10.value = <style type="text/css">div#header { background-image: url('
20 < lib.headerimage
30 = TEXT
30.value = ');}</style>
}
}
lib.headerImageText = COA
lib.headerImageText {
10 = IMG_RESOURCE
10.file.treatIdAsReference = 1
10.file.import {
cObject = TEXT
cObject.value = dummy.gif
cObject.override {
required = 1
data = levelmedia: -1, slide
listNum = 0
}
}
}
AND
page.headerData {
10 = COA
10 {
10 = TEXT
10.value = <style type="text/css">div#header { background-image: url('
20 < lib.headerImageText
30 = TEXT
30.value = ');}</style>
}
}
Fixed my problem ;) now the div#header has the correct background-url defined in the typo3 backend.

Plupload Create multiple sized thumbnails

I have found this thread on creating and uploading thumbnail images client side. The tread shows how to upload the first image then follow up by resizing it and uploading again. I was wondering if there is an easy way to add another step so the end result would produce and original, medium size and thumbnail
A better solution is to trigger QueueChanged in the FileUploaded handler, and then call refresh. This will initiate the upload again for the same file and you can set a property that you read in the BeforeUpload handler to adjust the file size.
Warning #1: you should upload the thumbnail after the full-sized image, otherwise the full-sized image may have some buffer issues and get cut off.
Warning #2: This will only work if the bind call for FileUploaded happens after uploader.init(), otherwise the uploader's own handler for FileUploaded will overwrite file.status back to DONE after your handler.
below is the original response from this thread Plupload Thumbnail
uploader.bind('BeforeUpload', function(up, file) {
if('thumb' in file)
up.settings.resize = {width : 150, height : 150, quality : 100};
else
up.settings.resize = {width : 1600, height : 1600, quality : 100};
}
uploader.bind('FileUploaded', function(up, file) {
if(!('thumb' in file)) {
file.thumb = true;
file.loaded = 0;
file.percent = 0;
file.status = plupload.QUEUED;
up.trigger("QueueChanged");
up.refresh();
}
}
is quite simple, I did that in my project, with two minor adjustments.
In the upload.php I made the directory information dynamically:
$diretorio = $_REQUEST["diretorio"];
$targetDir = 'upload/'.$diretorio;
and changed the code in the upload interface:
uploader.bind('BeforeUpload', function(up, file) {
if('thumb' in file){
//thumb
up.settings.url = 'upload/upload.php?diretorio=thumbs',
up.settings.resize = {width : 100, height : 75, quality : 60};
// medium size
up.settings.url = 'upload/upload.php?diretorio=medium',
up.settings.resize = {width : 200, height : 150, quality : 60};
}else{
up.settings.url = 'upload/upload.php?diretorio=full-size',
up.settings.resize = {quality : 100};
}
uploader.bind('FileUploaded', function(up, file) {
if(!('thumb' in file)) {
file.thumb = true;
file.loaded = 0;
file.percent = 0;
file.status = plupload.QUEUED;
up.trigger("QueueChanged");
up.refresh();
}
});
});
the answer given by Eduardo de Souza is very useful to me but there some change to work this code here can't upload medium file and the other is image can't be resize as resize param given i found some changes in my case which is:
var i = 1;
uploader.bind('BeforeUpload', function (up, file) {
if ('thumb' in file) {
if (i == 1) {
//thumb
up.settings.url = 'http://localhost/plupload_new/public_html/upload.php?diretorio=thumb',
up.settings.resize = {width: 80, height: 80, enabled: true};
} else {
// medium size
up.settings.url = 'http://localhost/plupload_new/public_html/upload.php?diretorio=medium',
up.settings.resize = {width: 800, height: 600, enabled: true};
}
} else {
up.settings.url = 'http://localhost/plupload_new/public_html/upload.php?diretorio=full';
}
uploader.bind('FileUploaded', function (up, file) {
if (!('thumb' in file)) {
file.thumb = true;
file.loaded = 0;
file.percent = 0;
file.status = plupload.QUEUED;
up.trigger("QueueChanged");
up.refresh();
} else {
if (i < 2) {
i++;
file.medium = true;
file.loaded = 0;
file.percent = 0;
file.status = plupload.QUEUED;
up.trigger("QueueChanged");
up.refresh();
}
}
});
});
have added a attribue enabled:true in resize param which make image resize and some checking with i variable for geting notice on medium url also,
i think this can be useful.

can I build a css class on the fly in tiny mce?

I'm using tiny mce, but I found it adds multiple spans with inline styles to the content for any applied style. Inline styles are not W3c Compliant, so must avoid inline css. Is it possible to create css class on the fly and apply to the selection, while editing content in tiny mce ?
Yes that is possible, but it took me some effort. What needs to be done is to write the class into the head of the editors iframe. Here is some example code which should work for IE,FF, Safari and point you into the right direction:
fonturl = "http://myfonts.com/arial.ttf"
csstext_to_add = '#font-face {font-family: "ownfont";src: url("'+fonturl+'");}'; // example
iframe_id = ed.id;
with(document.getElementById(iframe_id).contentWindow){
var h=document.getElementsByTagName("head");
if (!h.length) {
return;
}
var newStyleSheet=document.createElement("style");
newStyleSheet.type="text/css";
h[0].appendChild(newStyleSheet);
try{
if (typeof newStyleSheet.styleSheet !== "undefined") {
newStyleSheet.styleSheet.cssText = csstext_to_add;
}
else {
newStyleSheet.appendChild(document.createTextNode(csstext_to_add));
newStyleSheet.innerHTML=csstext_to_add;
}
}
catch(e){}
}
It is also possible to add that class as option into a dropdown (what takes some effort).
Thariama's answer was perfect. I'm using the tinyMCE jQuery connector for some of my pages and I have multiple instances of tinyMCE on the page. I made some modifications, but essentially its the same thing. I've created a text area field on the page that people can provide their own CSS. Also, I needed to change some CSS rules on the fly...
// function to change tinyMCE css on the fly
function checkCustomCSS() {
var $css = $('#page_css'),
newcss;
if ($css.val().length > 0) {
// since front end, we are wrapping their HTML in a wrapper and
// the tinyMCE edit iFrame is just using <body>, we need to change
// some rules so they can see the changes
newcss = $css.val().replace('#content_wrapper', 'body');
// loop through each tinyMCE editor and apply the code changes
// You could check the editor.id to make sure that the correct
// editor gets the appropriate changes.
$.each(tinyMCE.editors, function() {
var $this = $(this),
editorID = $this[0].id,
$ifrm = $('#' + editorID+ '_ifr'),
cwin, head, sheet;
if ($ifrm.length > 0 /* && editorID === 'OUR_EDITOR_ID_NAME' */) {
cwin = $ifrm[0].contentWindow;
head = cwin.document.getElementsByTagName("head");
if (!head.length) {
return;
}
sheet = cwin.document.createElement("style");
sheet.type = "text/css";
head[0].appendChild(sheet);
try {
if (typeof sheet.styleSheet !== "undefined") {
sheet.styleSheet.cssText = newcss;
} else {
sheet.appendChild(cwin.document.createTextNode(newcss));
sheet.innerHTML = newcss;
}
} catch (e) {}
}
});
}
}
Then in the tinyMCE init call I added and onInit call to setup changes to the #page_css , like this:
oninit: function() {
$('#page_css').on('change', function() {
checkCustomCSS();
});
}
Works like a charm.