Display images in template file - wordpress

I have one template file for the main page, after creating home page I have added text to check if it reflect changes on my home page or not and it was successfully displaying text. But when I try to add image by clicking on add media option then image is uploaded but not displaying on my page. What piece of code should be used to get this image on my template file or any other suggestions?

i'am pretty sure u need to SETUP CHMOD to 744
because its randomly set to 600.
This means it is not public visible.
1.You just need to get an FTP Programm,
2.Connect to your Webspace,
3.Go to your Uploadfolder,
4.Choose Your Image to Show with an RightClick,
5.and set CHMOD to 744.
I'll show u here (FLASHFXP)
(Attribute set = READ)
I need to do this for every picture, so u will need to do it too.

Okay i didnt knowed that ;)
You can also try to set the file permissions via rightclick on the File in your Windows-System.
Like This:
http://i.imgur.com/wBptC7s.png
make sure you have Admin-Privileges and the File is allowed to be read, change and execute, then it should work.
There is another Option
i recommend to Setup Wordpress to "DONT SORT UPLOADED FILES" to seperate folders like "per month", "per year" and this kind of Stuff, its better to have them Uploads all in ONE-Directory.(Thats my experience)
In the past i also had my Problems with the Uploads, and it all occurred just because of the "Multiple Folder Uploads" that Wordpress makes.
To change that go to:
Settings -> Media -> Sort Uploads by...
I recommend you to get a Free-Webspace for testing purposes, in my opinion its more comfortable to work online, and you can access it from everywhere you are :) Work never stops

you can add any custom field with this module https://wordpress.org/plugins/advanced-custom-fields/. And can easily add it to your pages and posts.

Related

How to change text in WooCommerce My Account Downloads area?

In the Downloads tab of the My Account area in WooCommerce, by default the text says "No downloads available yet". I need to change this text to something more specific.
I would rather not do this by copying plugin files to my child theme, but would prefer to do it with code snippet.
If anyone can help, it would be massively appreciated.
Many thanks for your time.
If you have access to ftp you can open the folder of Woocommerce plugin into a text editor.
You can find for the string and replace it by a more specific one directly into the code.
I think it's the cleanest way.
Let me know if it works.
You have different ways of doing this:
1- Copy wp-content/plugins/woocommerce/templates/myaccount/downloads.php to your theme folder inside /woocommerce folder and overwrite the part where the string is outputted -> recommended
2- Edit the woocommerce-[LANG_CODE]_[LANG_CODE].po file inside wp-content/languages/plugins but you would lose this if you update the plugin
3- If you have WPML installed you can do it via string-translation feature
4- Edit it via JS, not so clean but hey, it would work! :D

NextGEN Gallery still pointing to local drive

I recently moved a wordpress site from my C: drive to a pre-production environment, linux-based machine. The site works well-ish now.
I am using NextGEN galleries there and am using custom gallery theme. This is the problem: After moving, for some reason the galleries refer to the gallery with absolute path of the C: drive, which is obviously not working since this is another machine. I looked into the database to see if there's any value starting with C:\ and indeed I found out several of them and corrected them from C:\xampp\htdocs/wp-content/themes/subspace\nggallery\gallery-subspace.php to wp-content/themes/subspace\nggallery\gallery-subspace.php. However, after refreshing the page which used the gallery in WYSIWYG editor of WP and checking its settings, it stil referred to the template on the C: drive (namely, this is on the "display galleries tab", under "Customize the display settings", it is the value of the "Template" setting).
I checked the database again and there was no path like this in it. I refreshed the page, no difference. I got irritated and went to get a cup of coffee. When I returned, I ran the database query without any modifications again and found this in the wp_options table, option name "_transient_e4ae686b7454a142b0618b1ff15b38f4":
O:8:"stdClass":17:{s:2:"ID";i:4018;s:13:"post_password";s:0:"";s:10:"menu_order";i:0;s:16:"display_settings";a:20:{s:27:"override_thumbnail_settings";s:1:"0";s:15:"thumbnail_width";s:3:"120";s:16:"thumbnail_height";s:2:"90";s:14:"thumbnail_crop";s:1:"1";s:15:"images_per_page";s:2:"24";s:17:"number_of_columns";s:1:"0";s:15:"ajax_pagination";s:1:"1";s:20:"show_all_in_lightbox";s:1:"0";s:23:"use_imagebrowser_effect";s:1:"0";s:17:"show_piclens_link";s:1:"0";s:17:"piclens_link_text";s:14:"[Show PicLens]";s:19:"show_slideshow_link";s:1:"0";s:19:"slideshow_link_text";s:16:"[Show slideshow]";s:8:"template";s:73:"C:\xampp\htdocs/wp-content/themes/subspace\nggallery\gallery-subspace.php";s:19:"use_lightbox_effect";b:1;s:23:"display_no_images_error";i:1;s:18:"disable_pagination";i:0;s:17:"thumbnail_quality";s:3:"100";s:19:"thumbnail_watermark";s:1:"0";s:20:"ngg_triggers_display";s:5:"never";}s:8:"order_by";s:9:"sortorder";s:15:"order_direction";s:3:"ASC";s:10:"exclusions";a:0:{}s:13:"container_ids";a:1:{i:0;i:37;}s:22:"excluded_container_ids";a:0:{}s:9:"sortorder";a:0:{}s:10:"entity_ids";a:0:{}s:7:"returns";s:8:"included";s:20:"maximum_entity_count";s:3:"500";s:6:"source";s:9:"galleries";s:12:"display_type";s:35:"photocrati-nextgen_basic_thumbnails";s:4:"slug";N;s:8:"id_field";s:2:"ID";}
Which, as you can see contains the C:\ path again. I'm 100% positive this wasn't in the database a while ago and repeated the process with the same result (corrected this, waited a minute and it appeared again). Is it possible that this is pulled e.g. from some file?
You can follow the steps mentioned below:
In the wp-admin, go to "Gallery" -> "Other options" then, Click to "Lightbox effects" tab and Click "Show advanced settings" there, you'll find option to change the stylesheet and javascript urls. Change from 'localhost' to your baseurl or ( 127.0.0.1 ). Then save. Thats all.
Let me see if i can help.
Warning : do not try on production, get a dev or appropriate local version running. Also -- can't remember using NextGen, so my advice comes from a desire to do "best" practice in WP.
Easy try : kill cache if used such as JetPack or similar.
Regrading the _transient - should be able to kill -- this link Can I remove transients in the wp_options table of my WordPress install? seems to be dialed in. So if there is a cached element in the mix...bingo.
Next thing is the C:\...stuff rendered in the page source / html? If so, how is it rendered in the page (HTML please)? In other words, what part of the execution is writing C:\... to the page and why? WP has a bad habit of adding the site to the link (grr!). For example image src attribute will have the ``http://``` :
<img src="http://example.com/uploads/whatev..."
And this is written in the wp_posts table (fun migration issues esp if you change url) - so there is a slim possibility that the gallery info with the C drive ref is in the post or similar.
iD10t check: no config setting you missed in gallery? I hope there is not a 3rd party server/storage as #Hareesh mentioned!
Desperation (done this a few times) : dump the MySQL, get a large text editor and search for the string. Remember that weird stuff could be escaped as a " may turn into \" or the use of alternative "safe" quotes. See what can be learned.
Always an option : reinstall in a new WP site and see what/how things go.
If I think of anything else I will add it, but I just spilled how I would try to dissect the issue. GOOD LUCK.
You can use a search and replace tool to replace all C:/... instances with the correct ones.
But be sure to make a full DB backup beforehand, in case something breaks...

Force path sub.domain.com/file.jpg instead of domain.com/sub/file.jpg

Is this possible?
I use: WP latest version (3.3.2) and Cpanel Followed this tutorial to accomplish this: rsatechnologies.in/serve-image-media-files-from-cookie-less-domain.html
I've just managed to move all my post images in a "cookieless subdomain" and serve them in this format (path) when a user accesses the post: img.domain.com/year/month/file.jpg (1)
Now all my old images have this format but everytime I create a new post and upload an image, the image path shown is this: domain.com/img/year/month/file.jpg (2)
So what I'm trying to do is to force the site/server to use (1) instead of (2).
I've already tried everything in Media Settings tab, the only thing working is to write in the "Store uploads in this folder" and "Full path to files" fields the subdomain name ("img" that is).
Any suggestions?
I'm thinking is a Cpanel setting I'm doing wrong.
Many thanks!
The instruction posted here http://www.jafaloo.com/2011/09/11/host-your-wordpress-images-on-subdomain-for-better-page-loading/ is good. I have all my images at http://images.freedomwall.net/year/month/image.png instead of www.freedomwall.net/wp-content/uploads/year/month/image.png

Wordpress - Images not showing up in the Media Library

I have a huge problem with my Wordpress. My uploaded images don't list in the Media Library.
It is weird tho, it says I have 75 images, but display none. Take a look yourself.
Even weirder, if I go into gallery (the images you uploaded in the page itself), the images list just fine.
I already tried deactivating all my plugins, didn't work. Cache can be easily put out of the question, because it happened on at least 4 different computers, with Macs, PCs, and navigating with Safari, Firefox and Chrome.
Another interesting fact is that if I upload the image directly trough the computer (with the "From Computer" tab), everything goes fine. Another website on the same server works just fine too. And just to add to the complexity, when I go to the media page in the Wordpress Admin, all images show up just fine.
Oh, and before I forget... applying any filters, or doing a research in the media will always come up with the same problem.
So there... that's where I'm at.
I had a same problem just now, with missing media library images for my blog. The images appeared to be right there in the media library and were definitely on the actual web server (checked via FTP).
As Allen Z advised I did "check Settings → Media and make sure that Uploading Files folder is set to wp-content/uploads"
Mine were set to the default blank. I altered this to an absolute path http://www.example.com/wp-content/uploads
THIS DIDNT SOLVE THE PROBLEM when I refreshed the site in browser. However, I immediately changed the path back to blank (the default setting again) and everything came back! Woop
Everyone having this problem might want to try this before getting into the more technical fixes!
it was your permalinks... you must have changed to labeled-name... switch back to default.
that worked for me.
Check Screen Options (dropdown tab in the upper right hand corner of the page), and make sure there are sane settings for what to show on screen. All the column settings should be checked, and there should be a positive number of media items being shown on screen.
If that is ok, then check Settings → Media and make sure that Uploading Files folder is set to wp-content/uploads.
I believe these are the only settings that can be changed from the administrative screens.
Here's something a guy on Wordpress forum showed us. Add the following to your functions.php file. (remember to create a backup of your functions.php first)
add_filter( 'wp_image_editors', 'change_graphic_lib' );
function change_graphic_lib($array) {
return array( 'WP_Image_Editor_GD', 'WP_Image_Editor_Imagick' );
}
...it was that simple.
Well, Seems like there was a bug when creating custom post types in the function.php file of the theme... which bugged that.
I had this problem with wordpress 3.8.1 and it turned out that my functions.php wasn't saved as utf-8. Re-saved it and it
I faced same issue on my wordpress site. After the lot of debugging i fixed my problem step by step like this.
First add given below code your db-config.php
define('SCRIPT_DEBUG', TRUE);
define('WP_DEBUG', TRUE);
define( 'WP_DEBUG_LOG', true );
Then goto /wp-includes/js/wp-util.js files and find the code $.ajax(
options ) on line number 100 insert given below code into your file
deferred.jqXHR = $.ajax( options ).done( function( response ) {
try {
response = JSON.parse(response);
} catch (Exception) {
response = response;
}
Please check your may be resolved.
if you Removed constant from db-config.php
define('SCRIPT_DEBUG', TRUE);
define('WP_DEBUG', TRUE);
define( 'WP_DEBUG_LOG', true );
Then compress your /wp-includes/js/wp-util.js file code and put your compressed code into /wp-includes/js/wp-util.min.js
*change your own risk if your update your wordpress version your changed may be lost.
Did you ever change the directory of your Wordpress install?
I had a problem with not finding my uploaded images after changing the Wordpress location on my server. In Wordpress, I went to Dashboard-> Settings -> Media and changed the uploads folder in the "Store uploads in this folder" field.
Considering the files were not uploaded via media uploader, they are present in the server but there's no reference to them in your database (in a little more detail).
In order to fix it, install the Media Sync plugin. Once it's active, under Media > Media Sync > Scan Files and select the files you want to import by click the checkbox next to them. Make sure also you untick the selectbox Dry Run (test without making database changes).
Then, when the time comes for you to be ready, just click "Import Selected" and you should see something like this
Once it is finished, you can visit Media > Library and you'll see all your imported files there.
How did you upload those images; via FTP or through WP uploader? You have to upload images THROUGH WP uploader in order to show them in the image library.
Ubuntu stores uploads in /var/lib/wordpress/wp-content/uploads . So what you need is to have this directory within your wordpress installation. Something like:
sudo ln -s /var/lib/wordpress/wp-content/uploads /var/www/www.mysite.com/wp-uploads
(replace mysite.com with your domain, the file should exist) should do the trick.
(Note that I've not tested this with multiple wordpress installations on one server.)
Further note that to make upload work at all (but this wasn't the question), you need to change Settings / Media / Store uploads in this folder to
wp-content/uploads
(no leading slash).
check .htaccess file in root of wordpress, maybe there is a rule for /uploads directory.
if so, remove it. but be careful and check which plugin did it, so disable the plugin, first.

Wordpress image name same as page

Friends, i'm stuccoed with images in wordpress - please, help me understand where search for solution.
If you create webpage - www.wordpress.local/page1/01-0001 and you upload an image 01-0001 on that page, you can see, that when you'll visit www.wordpress.local/page1/01-0001, you'll see the page with image, not the page, that you created with text and images.
Any ideas how to solve it ?
PS Not renaming images :)
When you use the WordPress-uploader, the images are stored in /wp-content/uploads/, and WordPress takes care of using filenames that aren't already in use.
If you upload an image, e.g. via FTP, that has the same name as a WordPress-page, the server has to decide what it should serve; either the WordPress-page or the image. One URL = one file served.
In your case, the server decides for the image. You could of course change this configuration; but in all cases, one of the two files won't be accessible.
If you want to make both files accessible, you either need to rename the image or the WordPress-page.

Resources