I'm trying to theme one of my content types, which has images uploaded to each instance using the image attach module.
Using the developer module, I've found the iids value of the uploaded image (eg 305), but i'm having trouble finding out how I can actually display the image in my code. This line outputs the node id of the image which has been uploaded, but how can I then use that?
$image = $node->iids[0];
I've tried using hook_image, but I can't seem to get that working...
Thanks for any help.
This did the trick...
$nodeid = $node->nid;
$get_image = db_query('
SELECT p.filepath as imagefilename
FROM {image_attach} i
LEFT JOIN {image} a ON i.iid = a.nid
LEFT JOIN {files} p ON a.fid = p.fid
WHERE i.nid = %d AND p.filename = "recipe_thumb"', $nodeid);
$obj_image = db_fetch_object($get_image);
$imagefilename = $obj_image->imagefilename;
Related
I'm developing a multi language website with Typo3 v10.4.32.
Everything works fine. Except image metadata translation feature.
I uploaded an image, and I added translation for metadata (German is default)
After then I added page translation. In backend I see that images have default language metadata in both languages
If I click the image element to edit I see the correct behaviour: Typo3 is aware that the image has translation of metadata
In frontend unfortunately I see the problem: the default language metadata is shown
Typoscript template is simple:
config {
linkVars = L
sys_language_mode = content_fallback
sys_language_overlay = 1
sys_language_softExclude = tt_content:image
sys_language_softMergeIfNotBlank = tt_content:image
sys_language_uid = 0
}
# Default PAGE object:
page = PAGE
page.10 = TEXT
page.10.value = HELLO WORLD!
page.20 = CONTENT
page.20.table = tt_content
page.20.select {
orderBy = sorting
where = {#colPos} = 0
}
[siteLanguage("languageId") == 1]
config.sys_language_uid = 1
config.htmlTag_langKey = en
config.language = en
config.locale_all = en_US
[end]
Is the code below necessary ? since it is configured in yaml file
config.sys_language_uid = 1
config.htmlTag_langKey = en
config.language = en
config.locale_all = en_US
I could add translation in content elements, but images are supposed to be used in many places, so it becomes annoying to add the same text
I tried to search a solution, but I found very old similar issue with Typo3 v7 and the issue was supposed to be fixed in the next version Typo3 v8.
I suppose that the problem does not connect to NGINX ?
Maybe I need to add some code in LocalConfiguration ?
I'm kind of newbie and and I'm starting to be very fascinated by GSAP animations...
I found this with the code and everything: https://codepen.io/GreenSock/pen/QWjjYEw.
My problem is that in this animation I have some random pictures, but I want to use some local images that I have instead. Any suggestion of what to change?
I'm using Vue 2 and I put already the JS in the mounted :)
Thanks in advance!
I know that I should change this part but I don't know how
section.bg.style.backgroundImage = `url(https://picsum.photos/1600/800?random=${i})`;
I tried to duplicate this
part:section.bg = section.querySelector(".bg");
with:
section.bg = section.querySelector(".bg");
section.bg = section.querySelector(".bg2")
section.bg = section.querySelector(".bg3");
and then here :
section.bg.style.backgroundImage = "url('myImagePath')";
section.bg2.style.backgroundImage = "url('myImagePath')";
section.bg3.style.backgroundImage = "url('myImagePath')";
Nothing happens...if I put the imagepath inline style on the html I lose the animation.
First, your Q not related to vue.
Next inspect your code (For errors -- your main mistake section.bg is item inside a forEach loop - the path should be related to each iteration).
One way (DRY) to change the images from random images is to get the data-attribute of each bg item inside the forEach "section" loop.
One way to solve this.
Change the path from random path:
section.bg.style.backgroundImage = `url(https://picsum.photos/1600/800?random=${i})`;
To specific one for each iteration:
/*#### NEW CODE ####*/
let image_path = section.bg.dataset.image;
// Get images path from data attribute
section.bg.style.backgroundImage = `url(${image_path})`;
Read more:
Use_data_attributes: https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes
GSAP UtilityMethods: https://greensock.com/docs/v3/GSAP/UtilityMethods/toArray()
querySelector: https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector
I try to set my main tile with the templatew TileWide310x150SmallImageAndText02. I had a look at the sample code and took this out of it:
ITileSquare310x310SmallImagesAndTextList04 tileContent =
TileContentFactory.CreateTileSquare310x310SmallImagesAndTextList04();
tileContent.Image1.Src = "ms-appx:///Assets/Logo.png";
tileContent.TextHeading1.Text = "Cashflow";
tileContent.TextWrap1.Text = "Income: 500";
tileContent.TextWrap2.Text = "Spending: 400";
tileContent.TextWrap3.Text = "Earnings: 200";
// Create a notification for the Wide310x150 tile using one of the available templates for the size.
ITileWide310x150SmallImageAndText02 wide310x150Content =
TileContentFactory.CreateTileWide310x150SmallImageAndText02();
wide310x150Content.Image.Src = "ms-appx:///Assets/Logo.png";
wide310x150Content.TextHeading.Text = "Cashflow";
wide310x150Content.TextBody1.Text = "Income: 500";
wide310x150Content.TextBody2.Text = "Spending: 400";
wide310x150Content.TextBody3.Text = "Earnings: 200";
// Create a notification for the Square150x150 tile using one of the available templates for the size.
ITileSquare150x150PeekImageAndText01 square150x150Content =
TileContentFactory.CreateTileSquare150x150PeekImageAndText01();
square150x150Content.Image.Src = "ms-appx:///Assets/Logo.png";
square150x150Content.TextHeading.Text = "Cashflow";
square150x150Content.TextBody1.Text = "Income: 500";
square150x150Content.TextBody2.Text = "Spending: 300";
square150x150Content.TextBody3.Text = "Earnings: 200";
// Attach the Square150x150 template to the Wide310x150 template.
wide310x150Content.Square150x150Content = square150x150Content;
// Attach the Wide310x150 template to the Square310x310 template.
tileContent.Wide310x150Content = wide310x150Content;
// Send the notification to the application? tile.
TileUpdateManager.CreateTileUpdaterForApplication().Update(tileContent.CreateNotification());
This will show the tile correctly in the 150x150 size, but not in the wide. Then only the text is shown but not the image.
Here's a screenshot:
Thanks for your help!
NPadrutt
The SmallImageAndText Templates only show an Image on Windows, not on Phone.
Please refer to the template catalog for the direfences here.
Tipp: Template catalog is available at aka.ms/tiletemplates
I have a phantomjs script that is stepping through the pages of my site.
For each page, I use page = new WebPage() and then page.close() after finishing with the page. (This is a simplified description of the process, and I'm using PhantomJS version 1.9.7.)
While on each page, I use page.renderBase64('PNG') one or more times, and add the results to an array.
When I'm all done, I build a new page and cycle through the array of images, adding each to the page using <img src="data:image/png;base64,.......image.data.......">.
When done, I use page.render(...) to make a PDF file.
This is all working great... except that the images stop appearing in the PDF after about the 20th image - the rest just show as 4x4 pixel black dots
For troubleshooting this...
I've changed the render to output a PNG file, and have the same
problem after the 19th or 20th image.
I've outputted the raw HTML. I
can open that in Chrome, and all the images are visible.
Any ideas why the rendering would be failing?
Solved the issue. Turns out that PhantomJS was still preparing the images when the render was executed. Moving the render into the onLoadFinished handler, as illustrated below, solved the issue. Before, the page.render was being called immediately after the page.content = assignment.
For those interested in doing something similar, here's the gist of the process we are doing:
var htmlForAllPages = [];
then, as we load each page in PhantomJS:
var img = page.renderBase64('PNG');
...
htmlForAllPages.push('<img src="data:image/png;base64,' + img + '">');
...
When done, the final PDF is created... We have a template file ready, with all the required HTML and CSS etc. and simply insert our generated HTML into it:
var fs = require('fs');
var template = fs.read('DocumentationTemplate.html');
var finalHtml = template.replace('INSERTBODYHERE', htmlForAllPages.join('\n'));
var pdfPage = new WebPage();
pdfPage.onLoadFinished = function() {
pdfPage.render('Final.pdf');
pdfPage.close();
};
pdfPage.content = finalHtml;
I am uploading images for my site , I want every image uploaded to the server be of constant size.
So, when I display them from server to my site they can be uploaded quickly and the images use less server space.
code I am using to upload image using JSP.
logo_name = System.currentTimeMillis() + ".png";
File uploadedFile = new File("/www/static.appcanvas.com/"+logo_name);
item.write(uploadedFile);
Any related articles , some hints will be of great help
You didn't show us how you are parsing the upload. But, if "item is a org.apache.commons.fileupload.FileItem then you could use something lik the following.
BufferedImage bi = ImageIO.read(item.getInputStream());
Image img = bi.getScaledInstance(100,100,Image.SCALE_SMOOTH);
int w = img.getWidth();
int h = img.getHeight();
BufferedImage scaled = new BufferedImage(w,h,BufferedImage.TYPE_INT_RGB);
Graphics2D g = scaled.createGraphics();
g.drawImage(img,0,0,null);
if(g != null) g.dispose();
ImageIO.write(scaled,"png", uploadedFile);