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

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

Related

Image not displayed in postman (readable) using Laravel API

The image is saved to the database and file path specified in the response. Trying to display the image or download it, it is not the displayed. I tried to read the same image but it is working.
storage_path('app/uploads/images/3.png')
I read the 3.png stored in the directory and it is working without displaying error but to display the image it doesn't display image.
[![if (empty($imag)){
return response()->json(\[
'success' => false,
'message' => 'There was a problem creating the postcard!'
\], 201);
}
return response()->json(\[
'success' => true,
'data' => file_get_contents(storage_path('app/public/uploads/images/'.$exportName)),
'message' => 'Postcard created successfully!'
\],200);
}
The directory where the image is saved is storage/app/public/uploads/
I used php artisan storage:link
Your storage path is
App/upload/images/3.png
And you are uploding image in
App/upload/public/images/3.png
So database is storing above path and image is not uploded in above path
Just remove public from above path it works...

How to expose a image without saving to the public folder of Laravel

I'm making an application in Laravel where I need to save images that can not be accessible in the public folder along with my js and css.
I'm saving the images in the default Laravel folder, the storage/app folder. I wanted to know a way to expose these images without putting them in the public folder. I figured I could search the image first and send it to the view along with other data such as the user name and something else, but I'm not sure how to do it.
My configuration in the filesystems.php looks like this:
filesystems.php
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],
In my view, I'm trying like this:
<img src="{{ url("files/{$file->getContent()}") }}" class="rounded-circle">
In this case, I'm trying to put an image that the user uploaded.
Create and endpoint to download your file:
Route::get('/file/download', function() {
// get your filepath
$filepath = 'path/to/image/image.png';
return Response::download($filepath);
});
Then in your view:
<img src="{{url('/file/download')}}" class="rounded-circle" />

Laravel File Manager UniSharp Incorrect Image URL

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.

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.

Resources