What is the way to upload bulk images in wordpress? - wordpress

I have more than 500 images and I want to upload in WordPress media, I tried through FTP, WordPress changed images in different dimensions, and when I installed plugin "ADD TO SERVER " it uploads all the files.
I just want to add original images in the WordPress dashboard. Is there any way to upload bulk files in the WordPress media?

You can do it through FTP but go to settings before and change to import ORIGINAL size instead change dimensions.
You can find it under SETTINGS --> Media.
I have use 1024/1024 as max to avoid overload the server. You can change it on 2K(2048) or 4K(4096).

You can use the intermediate_image_sizes_advanced hook to prevent WordPress from getting the list of image sizes it normally uses.
The following code will feed an empty array to WordPress instead of the registered list of image sizes:
add_filter( 'intermediate_image_sizes_advanced', function(){
return [];
}, 10, 2 );
Running the Add to server plugin again after adding that code to your functions.php should not resize your uploaded images.

Related

WP All Import - Importing images into a post specific directory ie Property Listing folder

WP All Import - Importing images into a post specific directory ie Property Listing folder
Case
We have a setup to sync MLS listings into Wordpress with images, we have maybe 30-50 images per listings with ~500 listings per day being updated.
We then delete listings and images as they go off market.
Currently it takes a fair bit of processing power to lookup the listings media, delete the related media and then delete the posts as they date (say 100 listings are aged per day ~5000 images we need to hunt and delete.)
Secondly we have an issue with updating images and keeping the image path as the listing updates on a regular cycle and these media paths are then synced with other systems.
Having a logical directory path will make it significantly easier to stablise the logical url path and bulk delete the media off the server via CLI once when the listing is removed from the DB
So in an ideal world we would like to grab a custom field (the MLS number which is the listing unique id).
Create a directory in the uploads folder
Then any media that is uploaded and associated with a Post/listing, we would then upload the media into this folder.
What is the most elegant and desired method to
Create a post specific directory folder if it doesnt exist
Upload any media uploaded via WP All Import to be uploaded to this new specific folder
Make sure that the resizing and all the optimised tools know the relative location of each asset and the resized assets to be contained within each relevant directory
We had this logic with WP Property importer and it worked well.
https://wp-property.github.io/addons/importer/#gsc.tab=0
For those playing at home
In this example you create the post first
then run another import for the images which then uploads the images to the now created post_id folder within the custom folder.
You want to make sure you have the listing as a draft if no images
and only update records not create from the images.
function wpai_set_custom_upload_folder($uploads, $articleData, $current_xml_node, $import_id) {
// Change our upload path to uploads/customfolder.
$uploads['path'] = $uploads['basedir'] . '/listing/' . $articleData['ID'];
$uploads['url'] = $uploads['baseurl'] . '/listing/' . $articleData['ID'];
if (!file_exists($uploads['path'])) {
mkdir($uploads['path'], 0755, true);
}
return $uploads;
}
add_filter('wp_all_import_images_uploads_dir', 'wpai_set_custom_upload_folder', 10, 4);

How to Upload webp Image in Wordpress?

Google Webpage speed Give guide lines upload Image in webp format. Then Increase page speed.
In Wordpress CMS not accept webp file.
Hi do you ONLY need to upload the .webp images to wordpress? NOT display them?
if you just wanna upload the images, then go to wp-config.php and add one line to it:
define('ALLOW_UNFILTERED_UPLOADS', true);
then you can go to media library and upload the images,
however if you want to also display these images, here are some tools([useful article link][2]) that you may need to use, such as : cache enabler,
if any further questions please leave a comment. :)
Put this code at the end of the config.php file. Your problem will be solved
//** *Enable upload for webp image files.*/
function webp_upload_mimes($existing_mimes) {
$existing_mimes['webp'] = 'image/webp';
return $existing_mimes;
}
add_filter('mime_types', 'webp_upload_mimes');

Wordpress: Serve images from a CDN

I use a CDN to serve my images, which I upload into Wordpress. My settings were:
It worked perfectly but it doesn't work anymore since I updated to Wordpress 4.5. This are my settings now:
This filter doesn't work either:
function my_cdn_upload_url() {
return 'http://media.mydomain.com';
}
add_filter( 'pre_option_upload_url_path', 'my_cdn_upload_url' );
Does anyone know how should I serve my images from a CDN?
Thank you.
Looks like you upgraded from quite an old WP version, didn't you? Uploads folder and path options were removed in Settings -> Media a long time ago.
So what does your real path for uploads look like? It's not a standard domain.com/wp-content/uploads// correct?
If yes - where do new images get uploaded to after the upgrade?
Try playing around with https://wordpress.org/plugins/custom-upload-dir/ and see if it helps get your images back to CDN.
The easiest way is editing the content of "upload_url_path" in the wp_options table:
upload_url_path > http://media.mydomain.com
Thank you!
The problem with the approaches above are you won't have file write permissions to upload images to your CDN.
Another approach is to upload all of your images to somewhere - e.g. Amazon S3, or keep them on affiliate network CDNs - and then store your image URLs in postmeta for your posts or products.
You then need to alter your theme files to pull the images from the postmeta fields instead of from the featured image or thumbnail fields.
FYI - this approach will massively speed up imports since WordPress will create multiple sizes of images using up CPU and disk space.
I created a plugin to solve this:
https://www.wpintense.com/product/external-images/
There is a hidden admin page where you can find all the options:
http://localhost/wp-admin/options.php
Find the upload_url_path option and set a value.
Note:
After you give it value, then the "Store uploads in this folder" which is the upload_path, and "Full URL path to files" which is the upload_url_path options will also appear on the Media Settings page:
http://localhost/wp-admin/options-media.php
The options only appear on the Media Settings page if a value is already set. This is the code in WordPress Core that defines how it works:
/*
* If upload_url_path is not the default (empty),
* or upload_path is not the default ('wp-content/uploads' or empty),
* they can be edited, otherwise they're locked.
*/
if ( get_option( 'upload_url_path' ) || get_option( 'upload_path' ) && 'wp-content/uploads' !== get_option( 'upload_path' ) ) :
BEST WAY is to use w3 total cache.
It has a built in cdn support and of course you can use it's main functionality , caching , most useful to speedup website.

WordPress Media Manager

Is it possible to include an images folder that is then accessible via the admin section. I am creating a theme and want some background images available for the user, since I can not include them in the uploads folder is there another way?
Include your backgrounds into the images folder of your theme.
Create an options page that lets the user select a background and return the URL of the image.
<?php echo get_template_directory_uri().'/images/backgrounds/BACKGROUNDFILENAME.jpg'; ?>
You could try to in your functions.php create or register new "Attatchment" based posts using the URLS of your theme images or try using this...
https://wordpress.org/plugins/media-library-plus/

How stop wordpress creating thumbnails?

How can I stop Wordpress from making thumbnails? It uses a lot of my nodes, and memory!
How can I do this?
PS: My Wordpress site creates 3 images per uploaded image. (and I have galleies of 20-30 images per article => sooooooooo much nodes and memory)...
It's very simple to do this...
You have no visible option "stop Wordpress making thumbnails".
You must do the following:
Go to Settings -> Media
Uncheck "Crop thumbnail to exact dimensions (normally thumbnails are proportional)" if is checked
Set at Thumbnail size, Medium size and Large size the Width and Height to 0
Now Wordpress won't create you thumbnails.
I hope this will help you!
In wordpress when you upload new image that wordpress set it's thumbnail images accoring to set from admin panel or define in theme functions file.
Here is simple way for stop generating thumbnails by simple put below code in your theme function file.
function chnage_filter_image_sizes($sizes){
$sizes = array();
return $sizes;
}
add_filter('intermediate_image_sizes_advanced', 'chnage_filter_image_sizes');
Here if you want to generate own thumbnails with custome width and height whenever upload any image than just put parametes as below.
function chnage_filter_image_sizes($sizes){
$sizes = array('thumbnail_name'=>array('width'=>'120','height'=>'120','crop'=>true));
return $sizes;
}
add_filter('intermediate_image_sizes_advanced', 'chnage_filter_image_sizes')

Resources