Laravel File Manager UniSharp Incorrect Image URL - laravel

Displayed Image URL is incorrect. It should add "public/" in the url. How can I edit the url?

Instead of storing in public, I remove base directory as following:
'base_directory' => '',
'images_folder_name' => 'photos',
'files_folder_name' => 'files',
'shared_folder_name' => 'shares',
'thumb_folder_name' => 'thumbs',
And edit LfmHelpers.php under traits in line 113 as following:
$prefix = '/' . $prefix; And it works fine now.

If a UNISHARP then you need to have a look at this issue UNISHARP BUG as it suggest it is a bug.
The issue reporter find the solution by doing so
It worked after I removed the following from
vendor/unisharp/laravel-filemanager/src/views/script.blade.php
if (path.indexOf(ds) === 0) { path = path.substring(1); }
Hope it will solve yours.

Related

How to stop tinyMCE 5 to add ../../../../ before an absolute url received from alexusmai filemanager?

I am using Laravel 8, tinyMCE 5 and Alexusmai filemanager. My images are in the /public/assets/images folder.
The 'assets' disk is setup in config/filesystems.php :
// assets folder in public path
'assets' => [
'driver' => 'local',
'root' => public_path('assets'),
'url' => '/public/assets',
'visibility' => 'public',
]
FM returns the correct relatrive url, i.e. public/assets/images/xxx.jpg in a form field as a stand alone.
In tinyMCE 5, the same url is returned to the editor (the image is visible) but as soon as I look in the source3 code, the img scr is replaced by "../../../../public/assets/images/xxx.jpg". Why? How can I stop tiny to do that?
update...
It also seems that sometimestiny only adds ../ before public/assets... which results in the image not showing in the editor but displaying correctly in the website page. Weird!
How can I stop that please...
Seems like this is TinyMCE's "url handling": https://www.tiny.cloud/docs/configure/url-handling/
Try to add convert_urls: false to tinymce.init

Kcfinder Upload image issue

My site is a Codeigniter with kcfinder and ckeditor, and my issue is when I try upload and load an image, this image upload correctly in an autocreated folder /assets/kcfinder/.thumbs/images/, but When I select the image from server, the URL is wrong and I can not see it. How can I set the correct path?
I thing that the problem is that you need to add the base url in your image path
base_url() . 'images/' . $img;
I have solved the problem.
In ../assets/kcfinder/config.php I changed:
'uploadURL' from "upload" to Absolute url and in
'uploadDir' from "" to "upload" and it worked!
Thanks anyway.
You can also use below code to set your KcFinder config settings:
<?php
/**
* KcFinder has a SESSION key name 'KCFINDER'
* You can use this as setup your dynamic config vales
* if you set uploadURL and uploadDir via SESSION, KcFinder ignore config.php
* to get these values and it start using SESSION values
*/
$_SESSION['KCFINDER'] = array(
'disabled' => false,
'uploadURL' => 'http://www.example.com/upload',
'uploadDir' => 'var/htdocs/www/upload'
);
More: See Link

Laravel 4 imagecache intervention not displaying images

Here's the product page with an imagecached image: http://kmk-prof.kz/product/dx700lc
As you can see - image is not being displayed and has following url: /imagecache/catalogue/dx700lc-541a82fe99ac3.jpg
But when i try to browse that image just in my uploads folder - http://kmk-prof.kz/uploads/dx700lc-541a82fe99ac3.jpg it displays just fine.
Why could imagecache not work?
Here's the imagecache config.php:
'route' => 'imagecache',
'paths' => array(
public_path('uploads'),
),
'templates' => array(
'catalogue' => function($image) {
return $image->fit(213, 213);
},
),
It's very hard to tell you why the image is not displaying without any code.
Looking at the site, your image (in the html) is looking for a file in /imagecache/catalogue/dx700lc-541a82fe99ac3.jpg when your file is in uploads/dx700lc-541a82fe99ac3.jpg.
you can do 2 things:
change the code to load the file from uploads/dx700lc-541a82fe99ac3.jpg.
or, change your image path to /imagecache/catalogue/dx700lc-541a82fe99ac3.jpg
if you want more help, please post your code.
PS. your IMAGE URL link doesn't work ^_^

Why wysiwyg plugin in magento gets me broken links?

When I try to insert an image to the wysiwyg editor in Magento it places the right variable of the image path in the media directory.
But, wysigyg doesn't find the right path/url, example:
I inserted:
<p><img src="{{media url="wysiwyg/blog/Screen_Shot_2013.png"}}" alt="" /></p>
But, in the preview it gets me the next broken src:
<img src="https://localhost/index.php/admin/cms_wysiwyg/directive/___directive/e3ttZWRpYSB1cmw9Ii93eXNpd3lnL2Jsb2cvU2NyZWVuX1Nob3RfMjAxMy5wbmcifX0,/key/1a966015551bf00867319d23c9914b48/" alt="" data-mce-src="https://localhost/index.php/admin/cms_wysiwyg/directive/___directive/e3ttZWRpYSB1cmw9Ii93eXNpd3lnL2Jsb2cvU2NyZWVuX1Nob3RfMjAxMy5wbmcifX0,/key/1a966015551bf00867319d23c9914b48/">
And of course, it doesn't show the image. Also this happens with links and other media files.
System -> Configuration -> General -> Content Management -> Use Static URLs for Media Content in WYSIWYG for Catalog to Yes
The option wich Le Nguyen gave is not really a good solution.
Like hsanders said:
There are some pretty big drawbacks to doing this: The static URL will be a non-secure URL and If you change your base URL the URLs on the images will not update to reflect that are the two I can think of immediately.
A possible solution to "fix" the problem (not the right way in my opinion, but at least better than the static Url option) would be to add some code to the following file:
vendor/magento/module-catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php
Add on line 747:
'add_variables' => false,
'add_widgets' => false,
'add_directives' => true,
Also change
lib/web/mage/adminhtml/wysiwyg/tiny_mce/setup.js and add the following on line 384 (below content = editor.getContent();:
content = this.decodeContent(content);
Now you need to execute the following command to complete the process:
php bin/magento cache:flush
Hope this helps.
(Keep in mind you've just edited core files)
in your Form.php you configuration should be like below
protected function _prepareForm()
{
$model = Mage::registry('testimonial_data');
$form = new Varien_Data_Form();
$this->setForm($form);
$form->setHtmlIdPrefix('testimonial_');
$wysiwygConfig = Mage::getSingleton('cms/wysiwyg_config')->getConfig(array('add_variables' => false, 'add_widgets' => false,'files_browser_window_url'=>$this->getBaseUrl().'admin/cms_wysiwyg_images/index/'));
$fieldset->addField('content', 'editor', array(
'name' => 'content',
'label' => Mage::helper('testimonials')->__('Content'),
'title' => Mage::helper('testimonials')->__('Content'),
'style' => 'width:700px; height:500px;',
'state' => 'html',
'config' => $wysiwygConfig,
'required' => true,
));
}
hope it will work for you.

Magento admin login not working in chrome but works fine for firefox

I am just a newbie to the magento. I have installed magento on my localhost. After all the setup when I used the admin page to login I can't able to login in chrome browser even with my right username and password. But when I am trying to login in firefox there is no problem. So can some one really help me here to solve the problem?
I think there is the problem with session cookie with the chrome browser.
So just go through this directory
/app/code/core/Mage/Core/Model/Session/Abstract/Varien.php file
and comment out the line from 85 to 92 in magento (1.7.2 for my case). Like this
// session cookie params
/* $cookieParams = array(
'lifetime' => $cookie->getLifetime(),
'path' => $cookie->getPath(),
'domain' => $cookie->getConfigDomain(),
'secure' => $cookie->isSecure(),
'httponly' => $cookie->getHttponly()
);
*/
after that try to make login from your backend. Hopefully you can make login with chrome. This will definitely help you. If you are still facing the problem then just reply me.
try using 127.0.0.1 when you set up magento in localhost. I have also encounter same problem, that's the solution a have made and it works fine.
From System -> Configuration -> General -> Web, set Unsecure and Secure Base URL with IP Address. And try to login again.
GO to File at this location :- app\code\core\Mage\Core\Model\Session\Abstract\Varien.php
And commenting out the following (it's lines 85 to 102);
// session cookie params
$cookieParams = array(
'lifetime' => $cookie->getLifetime(),
'path' => $cookie->getPath()//,
//'domain' => $cookie->getConfigDomain(),
//'secure' => $cookie->isSecure(),
//'httponly' => $cookie->getHttponly()
);
//if (!$cookieParams['httponly']) {
// unset($cookieParams['httponly']);
// if (!$cookieParams['secure']) {
// unset($cookieParams['secure']);
// if (!$cookieParams['domain']) {
// unset($cookieParams['domain']);
// }
// }
//}
And use your credentials to logged in. Hope that should works for you!!!
Magento sees cookie_domain on core_config_data table when you try to login. If it is diffrent from your domain, you can not enter your admin panel, just refreshing the page, no error comes up.
Open core_config_data table from your database and search or filter the path column for web/cookie/cookie_domain and change it to null or your domain.
When it happens with me, the problems was because I make a directory move but the .HTACCESS files of main content was not moved to new path.
Check if your .htaccess file is in main content.
just apply the comment here...
file location : \app\code\core\Mage\Core\Model\Session\Abstract\Varien.php
/*
// session cookie params
$cookieParams = array(
'lifetime' => $cookie->getLifetime(),
'path' => $cookie->getPath(),
'domain' => $cookie->getConfigDomain(),
'secure' => $cookie->isSecure(),
'httponly' => $cookie->getHttponly()
);
*/
login as admin with internet explorer or other broswer. flush all caches.. And you will be able to log in using chrome . You can login in without having to modify any code
If you are using Magento 1.9, the file must be slightly different:
/app/code/core/Mage/Core/Model/Session/Abstract/Varien.php
$cookieParams = array(
'lifetime' => $cookie->getLifetime(),
'path' => $cookie->getPath()/*,
'domain' => $cookie->getConfigDomain(),
'secure' => $cookie->isSecure(),
'httponly' => $cookie->getHttponly()*/
);
/*if (!$cookieParams['httponly']) {
unset($cookieParams['httponly']);
if (!$cookieParams['secure']) {
unset($cookieParams['secure']);
if (!$cookieParams['domain']) {
unset($cookieParams['domain']);
}
}
}*/
It’s also important that you have a form key present, otherwise your form won’t get processed.
<?php echo $this->getBlockHtml('formkey'); ?>
This is my simple solution that helped me in the same situation. Try it for 60 seconds of your time.
In Google Chrome, in Developer Tools (right-click on any page element and select Inspect Element), go to the Resources -> Cookies tab. Delete the extra cookie for your original domain. Or set your base url domain to something else, or change the port.
As the accepted answer pointed out, the problem lies with chrome when accessing Magento on a localhost. Wrap the code in theapp/code/core/Mage/Core/Model/Session/Abstract/Varien.php with the following snippet, and the session parameter array will be only reset if you are on localhost (IP'127.0.0.1' or '::1').
// SNIPPET Part 1: add this before the original array definition
// -----------------------------------------------------------
if(in_array($_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1'))) {
$cookieParams = array();
} else {
// here comes the original code, thats what you should
// look for but not touch
// -------------------------------------------------------
// session cookie params
$cookieParams = array(
'lifetime' => $cookie->getLifetime(),
'path' => $cookie->getPath(),
'domain' => $cookie->getConfigDomain(),
'secure' => $cookie->isSecure(),
'httponly' => $cookie->getHttponly()
);
// SNIPPET Part 2: add the closing bracket
// ------------------------------------------
}
I have Magento ver. 1.14.2.1
changing varien.php did not solve my problem.
entering 127.0.0.1 instead of localhost in Dashboard configuration Web Base URL solved my problem.
I can still enter localhost in the url and it automatically redirects it to the ip format url.
For Magento 2
Instead of localhost on your WAMP please use http://127.0.0.1
{folder
path}\magento2\vendor\magento\zendframework1\library\Zend\Session.php
Go to & Comment as mentioned
public static function rememberUntil($seconds = 0)
{
if (self::$_unitTestEnabled) {
self::regenerateId();
return;
}
$cookieParams = session_get_cookie_params();
session_set_cookie_params(
$seconds,
//$cookieParams['path'],
//$cookieParams['domain'],
//$cookieParams['secure']
);
// normally "rememberMe()" represents a security context change, so should use new session id
self::regenerateId();
}
Having session/cookie problems with webkit browsers (e.g. Chrome) in Magento? Go to System -> Configuration -> Web -> Session Cookie Management and set “Use HTTP Only” to no. Have fun.

Resources