I just installed TinyMCE + jbimages plugin to be able to upload photos from the editor directly.
The upload works, but the display is breaking because of relative urls.
I add a blog post from
http://localhost/laravel-5/article/create
and uploading an image works and it even displays the image in the editor.
The image path in the editor says ../images/display-error1.jpg
but after submitting it and going back to the blog's page localhost/laravel-5/articles
the image doesn't display. It's pointing to localhost/laravel-5/images/image.jpg and skipping public altogether.
This is the upload path config in tinymce/plugins/jbimages/config.php
$config['img_path'] = '/laravel-5/public/images'; // Relative to domain name
$config['upload_path'] = $_SERVER['DOCUMENT_ROOT'] . $config['img_path'];
How can I fix this? Thanks.
I found the answer here: https://www.tinymce.com/docs/configure/file-image-upload/#images_upload_base_path
Just add images_upload_base_path: '/base/path/to-images'
Related
I am using yii2 and storing the image in root folder images. I have pointed the new domain to image folder and its working fine also in browser images are getting upload also showing in a browser but when I am trying to use them in IMG tag than it is not showing.
for ref please check below url
http://image.letspartii.com/advertisement/oJ9LFcAk2azVuGAHUrb8iyuuLqMJjUYa.png
1 - All images you want to display must be stored inside the /web folder.
2 - Use the relative path to call the img (starting inside de /web).
3 - Make sure to have the correct permission to the img folder and the file inside /web (permission and web/apache group).
Use the Url::base() method to get relative path:
<img src="<?= yii\helpers\Url::base().'/img/'.$filename; ?>"/>
I'm using tinymce with image upload using the package "laravel-tinymce-simple-imageupload". When the user enters some content in the textarea and clicks the form submit button I want to put the content in the textarea in a pdf file. I have the code below.
The issue is that in the pdf file, if is inserted an image in the textarea, the image doesn't appear in the pdf and in the pdf appears "Image not found or type unknown".
Do you know what can be the issue?
The image is stored like this in the content column of the certificates table:
<p>test<img src="/img/image_15zdbBr.jpeg" alt="" width="1200" height="900" /></p>
Code to get the pdf:
$certificateContent = RegistrationType::with('certificate')->where('id', $request->registrationType)->first();
$pdf = app()->make('dompdf.wrapper');
$pdf->loadHTML($certificateContent->certificate->content);
return $pdf->download('test.pdf');
Tinymce code has relative_urls as false:
tinymce.init({
selector:'textarea',
plugins: 'image code link',
relative_urls: false,
file_browser_callback: function(field_name, url, type, win) {
// trigger file upload form
if (type == 'image') $('#formUpload input').click();
}
});
I already use "setOptions(['isHtml5ParserEnabled' => true, 'isRemoteEnabled' => true])" but also dont works with that, it show the same error.
It seems that the issue can be because is necessary to change the url path of the image. But Im not understanding how to do that since the user only selects a image in the the tinymce textarea how to change the absolute path of that image.
This is a reported issue: https://github.com/dompdf/dompdf/issues/1659 .
Suggest you:
set relative_urls to true (this will set the image as img/image_15zdbBr.jpeg, and
set $dompdf->setBasePath($base_path) where $base_path is where the files sit. (https://github.com/dompdf/dompdf/wiki/Usage#setbasepath)
Edit with salient bits from chat:
As you are using a wrapper for Laravel, You need to get a handle on the domPDF class which you will do through $pdf->getDomPDF()->setBasePath();
As the relative file path is ../../../image/file.jpg, this means "start at the "base directory, go back one, go back one, go back one, go into img/, find file". So the "base directory" needs to be ahead of the the files to take accound for the fact you're going back.
Working example:
Your actual file is located (for real) in /home/john/projects/proj/public/img/image.jpeg
Relative file path (provided) = ../../../img/image.jpeg
So you configure your setBasedirectory = /home/john/projects/proj/public/a/b/c/
Combined this gives you /home/john/projects/proj/public/a/b/c/../../../img/image.jpeg
Which is the same as /home/john/projects/proj/public/a/b/../../img/image.jpeg
Which is the same as /home/john/projects/proj/public/a/../img/image.jpeg
Which is the same as /home/john/projects/proj/public/img/image.jpeg = Bingo.
If this doesn't work, adjust your setBaseDirectory until you get the right path.
I've been looking for a way to make a custom direct access images on wp-content uploads folder since a year ago, but I still didn't found how to serve / display image in wp-content/uploads folder using custom script (maybe php)
Please take a look at my screensshot here : http://prntscr.com/30sdb8
you can see this wp-content/uploads are still have some additional code, and even this page source are hidden with an image (the same image)
is there anyone know how to do that on a worpdress website?
Thanks for answering my question
Updated
because of some unclearly information in my previous question here I try to explain as clear as I can.
In a default wordpress website if a user direct access an image from wp-content/uploads/ directory (for an example : www.domain.tld/wp-content/uploads/2014/04/image-name.jpg )
there will be only an image and a blank background, but in my screenshot example you can see that there are some additional code in header and footer.
my question is how to make modification like that in wordpress? so I can display a header and of footer on my wp-content/uploads/ Url pages
ps : the website I mean is lincah.com , you can go to google image, site:lincah.com then click on 1 image on the search result you'll be brought to the page I mean.
I hope thats clearly enough.
Thank you
What I could make out is you need a PHP script that could fetch all the images from uploads folder and display on the page.
<?php
$images_list = glob("wp-content/uploads/" . "*");
foreach($images_list as $image) {
echo '<img src="' . $image . '" /> <br />';
}
?>
For some reason, on my server, images do not display if they're remotely (or locally) embedded in an HTML page, but they do work when visited directly.
Embed code:
<img src="http://c.beastsmc.com/banners/creative.png"/>
Here's a fiddle showing the image not displaying: http://jsfiddle.net/gKHM7/
Here's the direct image, which works: http://c.beastsmc.com/banners/creative.png
The .htaccess file is empty.
Any ideas?
As jcansyi mentioned above (upvote him!), the problem was that AdBlocker blocked the image. The reason it was blocking it was the name of the folder (banners). AdBlockPlus blocks any URL with /banners/ in it.
I have FCKEditor for uploading images to newsletter, but the images in the editor are placed with relative path.
/uploads/media/1.jpg
How can I enforce to use
http://www.example.org/uploads/media/1.jpg
when creating the HTML content inside the editor.
in "fck/editor/filemanager/connectors/php/config.php"
set this param :
$Config['UserFilesPath'] = "http://www.example.org/"