CAnnot upload image after upgrade to 1.1.9.3 Magento - magento-1.9

Maybe you have seen this question before, but I still cannot find a solution after I have upgraded Magento to 1.1.9.3. Can some one explain the solution 3 in this link?
https://community.magento.com/t5/Security-Patches/SUPEE-8788-Solutions-to-Different-Problems/td-p/52572
and in main template that following is not overwritten by another
theme.
Where is main template?

Image Button Problem / Not Uploading pictures / Flash Uploader replaced
In latest version the existing flash uploader is now finally replaced.
Solution 1 - Delete the following folder /skins/adminhtml/default/default/media/ or following files in the folder
Solution 2 - If you have CreareSEO module add following to file
app/design/adminhtml/default/default/template/creareseo/catalog/product/helper/gallery.phtml
Between Line 84 and 85 (new line 85)
<?php echo Mage::helper('catalog')->__('Maximum width and height dimension for upload image is %s.', Mage::getStoreConfig(Mage_Catalog_Helper_Image::XML_NODE_PRODUCT_MAX_DIMENSION)); ?>
Remove line 97 and insert
var <?php echo $_block->getJsObjectName(); ?> = new Product.Gallery('<?php echo $_block->getHtmlId() ?>', <?php echo $_block->getImageTypesJson() ?>);
Solution 3 - Where themes overwrite header files and will not upgrade / use magento default header
In Admin section: /app/design/adminhtml/default/default/layout/main.xml be sure that following line is there
<action method="addJs"><script>mage/adminhtml/uploader.js</script></action>
and in main template that following is not overwritten by another theme.
<action method="addJs"><name>lib/uploader/flow.min.js</name></action>
<action method="addJs"><name>lib/uploader/fusty-flow.js</name></action>
<action method="addJs"><name>lib/uploader/fusty-flow-factory.js</name>

Related

PhpStorm - Make blade recognize (and autocomplete) variables

The problem
I'm working on a project, that has a lot of blade-files. But PhpStorm doesn't seem to play nice, with mixing <?php ... ?> and #php ... #endphp.
As you can see here, PhpStorm says that $position_link isn't defined, yet it is just a few lines above (this image serves the purpose of displaying the IDE-warnings/errors):
It's the same problem with $data, but as you can see, on line 98, it doesn't complain. Hmm!
The question
Ideally: How do I make PhpStorm understand this code better?
Next best thing: How do I hide these warnings?
Solution attempt 1: Blade Plugin
I can see that the plugin called 'Blade' is now bundled with PhpStorm.
Solution attempt 2: Googled around
I found a bunch of articles about this:
Type hinting works within php block but not in blade.
My comment: I guess this is the same issue. If PhpStorm thinks the variable doesn't exist, then I assume that it can't autocomplete it either. The solution on that article is to open a new issue. Both linked issues are incomplete.
Make variables autocomplete in the PhpStorm 9 for Blade templates
My comment: This was 6 years ago. I refuse to believe that nothing has happened on this area since. The marked solution is that it isn't supported. The most upvoted is to add this on the line before: #php /** #var $position_link #endphp. But it doesn't work. And even if it did - then it will bloat the code immensely.
Solution attempt 3: <?php instead of #php
I also tried changing this:
#php
$position_link = 'left';
if( App\isset_with_value( $data, 'position_link' ) ){
$position_link = $data->position_link;
}
#endphp
<div class="links-wrapper" style='text-align: {{ $position_link }};'>
with this:
<?php
$position_link = 'left';
if( App\isset_with_value( $data, 'position_link' ) ){
$position_link = $data->position_link;
}
?>
<div class="links-wrapper" style='text-align: {{ $position_link }};'>
... But is still shows the error.
Solution attempt 4: Remove Blade completely
If I just write the whole thing in good ol' PHP, then I get a stylelint error:
I know this is another problem, which has to be solved in my Stylelint-settings. I figured I'd just show that this isn't a solution (for me) either.
My system specs
MacBook Pro 16-inch, 2019
OS: Big Sur, 11.6
PhpStorm version: 2021.2.2 - PS-212.5284.49

dynamically change CSS with fat free framework?

I am trying to use some shortcodes inside my CSS so I can change them all at once with fat free variables.
For example from my config.ini:
accentColor=8f0
And in my style.css would be:
.addToCart:hover {
background-color: #[[accentColor]];
}
in my header.htm view file:
<link rel="stylesheet" href="{{#BASE}}/ui/css/style-user.php">
style-user.php:
<?php
header("Content-type: text/css; charset: UTF-8");
$fullpath='http://'.$_SERVER['SERVER_NAME'].'/ui/css/style.css';
if(file_exists('style.css')){
$search=array('[[accentColor]]','[[protectPhotoOpacity]]','[[protectPhotoPosition]]');
$replace=array('{{ #accentColor }}','0.3', '30');
echo str_replace($search,$replace,file_get_contents($fullpath));
} else {
echo "body {background-color: white;}";
}
?>
It's finding style.css fine and the other shortcode changes are working. {{ #accentColor }} is not working in the style-user.php file but works fine in header.htm. What am I missing?
Is there a better way to go about doing this?
EDIT:
I put the .php in the root folder instead of the /ui/css folder. Here's what I ended up with:
<?PHP
$f3=require('lib/base.php');
$f3->config('options.ini');
$f3->set('CACHE',TRUE);
echo Template::instance()->render('ui/css/style.css','text/css');
?>
And then inside the css file, just use the {{ #accentColor }} template variables like normal.
It's finding style.css fine and the other shortcode changes are working. {{ #accentColor }} is not working in the style-user.php file but works fine in header.htm. What am I missing?
I assume that you are using F3's templating system to render header.htm. It looks like you are not using the template system to render the CSS file.
I would propose to utilize the template system and template variables (like {{ #accentColor }}). Then you would be able to cache the parsed template files and/or the resulting CSS files for performance reasons.
Your code could look similar to the following snippet:
<?php
// Setup F3 here.
// You could utilize the routing system or skip routing and return only the CSS file.
// I would prefer the routing system with a cached route.
echo Template::instance()->render(
'style.css', // Your CSS file stored in one of the `UI` directories
'text/css',
[
'accentColor' => '#123456', // Specify variables or forward variables from a configuration file
]
);
Of course, there are other solutions. I would either register a CSS route or provide a PHP file that is bootstrapping F3 to render the CSS file with your variables.

ACF fields in another plugin

I need to add additional images next to post title, in this case decided to use ACF and add fields (image) into another plugin (Event Schedule). After I added fields in ACF I was trying to add some code from ACF documention however it doesnt work..
P.S. Every post will have different images based on their type. You can choose it while you are editing specific post.
In ACF field menu I chose to return format Image Array.
Tried with all return formats: Image Array, Image URL and Image ID. As I understand plugin cant find the variable acf_name and the image source is left blank.
<div class="wcs-class__meta">
<div class="wcs-class__inner-flex">
<h3 class="wcs-class__title" :title="event.title" v-html="event.title"></h3>
// Using this code from official ACF documentation
<?php
$acf_name= get_field('acf_name');
if( !empty($acf_name) ): ?>
<img src="<?php echo $acf_name['url']; ?>" alt="<?php echo $acf_name['alt']; ?>" />
<?php endif; ?>
</div>
</div>
Now nothing happens, no errors, nothing. However, also it doesnt show those images I want.
Files in the plugins folder do not have access to global functions like get_field();. You can overwrite most plugin files in your theme, in which you should have access to global functions. Keep in mind that when the plugin you override gets updated, the file your are overriding will not. This could cause security issues.
The following article talks about the right ways of custmizing plugins: https://iandunn.name/2014/01/10/the-right-way-to-customize-a-wordpress-plugin/

How can I call the first image in a folder to display in my img tag?

I want to be able to call the first image from a folder. The reason behind this is that the file name will always be changing as the user will be able to put whatever image they want inside of the template.
Using PHP:
Step 1
use glob() function to search for all the pathnames matching pattern for image extensions {jpg,png,gif} inside your directory path using GLOB_BRACE
Step 2
Confirm atleast one image is found
Step 3
Use img tag to display the image
<?php
$images = glob("path/to/your/folder/*.{jpg,png,gif}", GLOB_BRACE);
if(isset($images[0]) && file_exists($images[0])){
echo '<img src="'.$images[0].'"/>';
}
?>

Locate and edit the main HTML file in magento store

I need to add a shadow effect png picture to the top banner in my Magento website tamween.biz, I could do this on my local server using firebug by adding a new class in the right coding area and I have made all selector properties in the bootstrap.css file.
This test was very successful, The problem is I don't know where to locate the real HTML file in the server to edit these changes?
HTML code that calls image is in root/app/design/frontend/<package>/<theme>/template/page/html/header.phtml
Image's path is stored in System => Configuration => General => Design => Header => Logo Image Src
Any skin is located in root/skin/frontend/<package>/<theme>/css
Magento HTML page is made up of blocks, and each block has a template file.
To find out where each block template file is you can add some code to the core and get rid of it after you are done.
Open app/code/core/Mage/Core/Block/Template.php:241. This should be in the method fetchView and then edit the line having the include code to the following
if (strpos($includeFilePath, realpath($this->_viewDir)) === 0 || $this->_getAllowSymlinks()) {
echo "<!-- template hint start\n";
echo $includeFilePath."\n";
echo get_class($this)."\n";
echo "-->";
include $includeFilePath;
echo "<!-- template hint end\n";
echo $includeFilePath."\n";
echo get_class($this)."\n";
echo "-->";
} else {
This will add HTML comments telling you about the template file path and what $this means in that context.
(Reference)
In magento go to System - > configuration and set template hints yes.
This way you will see each template section from where static blocks will come from.
If you have created your custom theme then go to
root/app/design/frontend//yourtheme/template/page/html/header.phtml
if not then go to
root/app/design/frontend/base/default/template/page/html/header.phtml
and the n search for
<img src="<?php echo $this->getLogoSrc() ?>">
this is the code that output the image.you can add css class to it.