Custom wp-content/upload image page - php

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 />';
}
?>

Related

Laravel 5: TinyMCE 4 images have broken urls

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'

Wordpress Header Image

I am trying to edit the header of my website to use my logo in the header. In the header.php file under the "Display Logo Image or Site Title" code here is what I have after putting in the image link:
$options = get_option('zeefocus_options');
if ( isset($options['themeZee_general_logo']) and $options['themeZee_general_logo'] <> "" ) : ?>
<img class="logo-image" src="http://i.imgur.com/02WuoWa.png" alt="Auto-Platre" /></a>
I saved and uploaded the file, but the webpage is still the same. Do I need to edit anything in the Wordpress admin?
Without more info this question is kind of hard to answer but here are a few things to try:
Clear your cache if you have it enabled
Your theme might have a built in header option, in which case you can upload the image to directly through the theme settings

image File permission is not working

The file is created when the user registers successfully , each user folder thats created is only read/writable by daemon not by admin or anyone else,
the main users folder is created by me and has all permissions set that needs be and it doesnt even feature the name daemon
The problem I have is that, when I upload an image, it uploads to the directory of that user(the right directory of the users name) and I see it there but the problem is when I want to echo the image onto the page it does not work.
I use the moveupload() function and it moves but it is not able to show the image on the page, all other information is shown on the users page like name ect , but just not the image .What can I do?
This is the code snippet to create the file when user registers . I'm using a mac
if(!file_exists("user/$u")) {
mkdir("user/$u",0755);
}
Are you using proper HTML syntax for echo-ing your image? You can't simply do an echo $imagePath; in PHP, you must user proper HTML syntax for the output.
echo "<img src='".$imagePath."' />";
Edit:
If you're using HTML mixed with php, the HTML output would be as follows:
HTML
<img src="<?php echo $log_userpath . "/" . $main_userimage;?>" width="220px" height="300px" />

adding a background-image to body in a cakephp layout with jQuery

I'm using cakephp 2 and I'm trying to allow my users to upload an image which is then used as the background for their page.
I have the images uploading fine and saving to a (webroot)files/User/$userid/$bodybgimage. I've also got the name of the image in the database.
Trouble is I want because I don't know in advance what user id is going to be requesting their background image I can't put their background in the stylesheet, so I'm trying to get it added in the default layout. I've tried to add with jquery: (the image filename is in $bodybgimage)
<?php if(!$bodybgimage == '') {?>
$('body').css('background-image', 'url('<?php echo '../files/User/'.$userId.'/'.$bodybgimage; ?>')');
<?php }?>
But this seems to just remove everystyle I had for the body!
I also tried doing adding it straight to the body tag like so:
<body<?php if(!$bodybgimage == '') echo ' style="background-image:url(../files/User/'.$userId.'/'.$bodybgimage.')"';?>>
But again to no avail. Can anyone help me out. I know the image and all's there because if I put the background-image style in the stylesheet the image pops up ok. There must be a sensible way to do this that I'm missing. Plz help!
Please can you try to omit the "../" before the files as i assume that your images founded in a folder named files beside your script not ?

link with same url in php

I have some thumbnail images with its larger version.I placed the thumbnail images in a page.Now for link I just gave a link
<img src="thumbnail1.jpg>
but for this I have to make different pages for showing larger one.I want to give a link to show them in a single page.means whenever I will click the thumbnail it will open the larger one in a page with the same url but with its name like
imagegallery.php?news=images/largerimage1/13.jpg
imagegallery.php?news=images/largerimage1/14.jpg
so how to do that?
Pretty basic stuff, I suggest you get to read some PHP tutorials on the internet to get some knowledge on one thing and another.
The ?news= part in your URL is a parameter that can be read by PHP. This type is known as $_GET. To get this part you would need $_GET['news'] so if we'd use your first link and place this inside a script: echo $_GET['news']; the page would say images/largerimages1/13.jpg.
In order to get the image loaded on your website we need some simple steps, I'm changing the news parameter into image, that suits better for your script since it ain't news items:
<?php
// Define the path (used to see if an image exists)
$path = 'your/absolute/path/to/public_html/'; # or wwwroot or www folder
// First check if the parameter is not empty
if($_GET['image'] != "") {
// Then check if the file is valid
if(file_exists($path . $_GET['image'])) {
// If an image exists then display image
echo '<img src="'. $_GET['image'] . '" />;
}
}
?>
Below this script you can put all your thumbnails the way you want. Ofcourse, also for these thumbnails there are some automated options. But I strongly suggest you get a good look at the script above and some beginner PHP tutorials so you completely understand the example given. This still isn't the best method, but it's kicking you in the right direction.
if your imagegallery.php is in root of your domain, you can just add slash as a first char to links like this:
<img src="thumbnail1.jpg>
else you will have to write some php function which it returns BaseUrl of your web. Then it should looks like this:
<img src="thumbnail1.jpg>
maybe you can something like this,
Techincally, there is no thumbnail image, just a stretch version of the regular image
I don't understand which part you don't know how to do:
- the link part?
it should look like
<img src="thumbnail1.jpg>
- or the PHP part (the file called imagegallery.php)?

Categories