Magento - Category Thumbnails - How to use SVG? - magento

I cannot upload SVG-images as Category-Thumbnail-pictures in Magento (CE, 1.8). Just "normal" image-formats like jpg or png seem to work.
Does anybody have an idea?

You need to rewrite or modify this Model
class Mage_Catalog_Model_Category_Attribute_Backend_Image
app/code/core/Mage/Catalog/Model/Category/Attribute/Backend/Image.php
In line 60
$uploader->setAllowedExtensions(array('jpg','jpeg','gif','png','svg')); // add the file type SVG to the allowed extension array.
It will work just fine

Soltion is:
class Mage_Catalog_Model_Category_Attribute_Backend_Image
rewrite file
app/code/core/Mage/Catalog/Model/Category/Attribute/Backend/Image.php
update code
$uploader->setAllowedExtensions(array('jpg','jpeg','gif','png','svg'));
$uploader->setAllowRenameFiles(true);
// Avoid Validation for SVG
// $uploader->addValidateCallback(
// Mage_Core_Model_File_Validator_Image::NAME,
// new Mage_Core_Model_File_Validator_Image(),
// "validate"
// );
And boom , you are done!!

Related

GSAP Scrolltrigger Parallax Sections

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

Change An Image On A Website Using Tampermonkey

I want to change an image on a website, so that every time I visit, it shows the image that I want it to show and not the one that it normally shows.
Does anyone have the Tampermonkey code to do this?
Just change the src attribute. For example, say your image has the id "blah":
document.getElementById("blah").src = "http://......"
If you're not just searching by id, you could use something like document.querySelector(.....) instead.
Then put this inside a TamperMonkey script and make sure your code is firing on the correct websites (the #match part of the UserScript section in your script).
The following example is a tampermonkey script that runs on all websites. The script searches for an image of a cat and replaces it with an image of a dog. This script uses jQuery to select the image and modify its value.
// ==UserScript==
// #name Image Replacer
// #version 1.1
// #description Image Replacer
// #require http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
// #match https://www.pinterest.com/pin/*
// #grant none
// ==/UserScript==
/*globals $*/
var old_url = "https://i.pinimg.com/564x/21/64/6a/21646ad49e3860218f44b456153c7594.jpg"
var new_url = "https://i.pinimg.com/564x/59/9b/bb/599bbb49d7a3bb5546ff4017e9eb76ce.jpg"
$(document).ready(function(){
alert("Hi There!");
$("img[src='"+old_url+"']").attr("src", new_url);
alert("Replaced pictures successfully");
});
You can run this script on this Pinterest Website.

How change the header labels TYPO3 7 LTS fluid_styled_content

I use TYPO3 7.6.2 LTSwith the new fluid_styled_content. It's brilliant! Very easy to change the header types or upload elements or text/image stuff ...
But how can I change the Labels at Backend-TCA for the Header element f.e. Is it still over TSconfig or a locallang-file? And where it is?
And how can I disable some headlines. I only use Layout 1-3. If I found this, i'll never go back to css_styled_content..
Thanks for your advice.
The old way was like this TSconfig ..
TCEFORM.tt_content.header_layout.altLabels {
1 = H2 rot
2 = Grafische Ueberschrift
3 = Versteckt (CSS)
4 = Nicht ausgeben
}
TCEFORM.tt_content.header_layout.removeItems = 5,6,7,8,9,10,100
And TS setup
lib.stdheader = CASE
lib.stdheader {
key.field = header_layout ..
Nothing should have changed within TSconfig ... tested it ... works like a charm.
The frontend rendering of the header is not defined via TS any more (mostly), but via partials. Checkout the path settings in the TypoScript of lib.fluidContent. You can overwrite the default templates, partials and layout with your own fluid templates.

How do I show only 1 scaled image in fineuploader

I want to upload 2 scaled images and I do not want to upload the original image. To do this, I set sendOriginal to false. If I set hideScaled to true, no files show in the uploader. If set set hideScaled to false, both scaled images show up in the list. I realize that the documentation says not to use both options this way. Is there another way to achieve what I want? How do I make fineuploader show only 1 file on the file list no matter how many scaled images it has?
I ran into this exact same problem. I also wanted to rename the larger scale to match the original filename and to pass a custom parameter so the server script could sort the images into the db based on scale size.
I used this method as a hackish substitute for an onScaled event. If anyone is still interested.
// Must be onSubmitted, not onSubmit or the DOM element won't be rendered yet.
onSubmitted : function(id, name) {
// scaling.sizes.name = 'thumb'
if (name.toLowerCase().lastIndexOf(' (thumb).jpg') !== -1) {
// Hide the element displaying the thumbnail.
qq(this.getItemByFileId(id)).hide();
// Good place to include any custom parameters based on scale size.
this.setParams({gpsize : 'thumb'}, id);
}
// scaling.sizes.name = 'large'
else if (name.toLowerCase().lastIndexOf(' (large).jpg') !== -1) {
this.setParams({gpsize : 'large'}, id);
// If needed rename file in this event, not before, since filename
// is the hackish hook needed to connect scale size to file id.
var newName = name.slice(0, name.toLowerCase().lastIndexOf(' (large).jpg')) + '.jpg';
this.setName(id, newName);
}
return true;
}
It's not perfect, but it gets the job done without bushwhacking through the script files.

FPDF Error - Can't get image to appaear on PDF

I have a PDF with fillable forms. I can successfully fill the forms and save the new PDF to my server no problem, but I cannot place an image on the PDF. When I remove the Image(....) line the script works great. When I add it back it I get the error.
I think it's trying to look for the method in the wrong file, originally I only included fpdm..php but I tried adding back fpdf.php and it did not help. Not sure what I'm doing wrong.
Error:
Fatal error: Call to undefined method FPDM::Image() in /home/.../formPDF.php on line 113
Code:
require('../forms/pdf/fpdf.php');
require('../forms/pdf/fpdm.php');
$pdf = new FPDM($formPDFLocation);
$pdf->Image('images/sig_37-1405313221.png', 100, 20);
$pdf->Load($fields, false); // second parameter: false if field values are in ISO-8859-1, true if UTF-8
$pdf->Merge();
$filename= "../forms/generated/" . $ffID;
$pdf->Output($filename.'.pdf','I');
FPDM is not really related to FPDF but simply a script of a FPDF user. You cannot use FPDF methods on an FPDM instance.
If you search for an all in one solution for such task you may take a look at the SetaPDF-FormFiller component (not free!).
I was able to save the PDF to my server and then add the image but lost the form contents. Code for anyone that is interested in this half solution:
Code for adding image:
<?php
require_once('fpdf.php');
require_once('fpdi.php');
$pdf = new FPDI();
$pdf->AddPage();
$pdf->setSourceFile("16.pdf");
$tplIdx = $pdf->importPage(1);
$pdf->useTemplate($tplIdx, 10, 10, 100);
$pdf->Image('car.jpg',20,100);
$pdf->Output();
?>

Resources