How to Upload webp Image in Wordpress? - 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');

Related

Remove date in images's url on wordpress?

When I upload images in Wordpress I get:
http://test.net/wp-content/uploads/image name**-20210601-071141**.jpg
however I would like it like this:
http://test.net/wp-content/uploads/image name.jpg
See how the date and 071141 isn't in the URL on the 2nd one? That does not happen for all images that I upload but that happens only for some images
Anyways, is that possible? To remove the what is between ** date and that code stamp from the Image URL?
Notice that On Media Organize my uploads into month- and year-based folders is UNCHECKED and even I remove the old images and regenerate the thumbnails again . I get the same problem !!! I don't have any pluging can do something on images
you can apply rule in .htaccess file
RedirectMatch 301 ^/([0-9]{4})/([0-9]{2})/(.*)$ http://yourwebsite.com/$3

Wordpress media-uploader save to a specific location

I'm trying to implement a plugin allowing to download an image and save it to a specific location (relative to my plugin path - ie plugins/my_plugin/img) rather than in the default WP location.
I'd like to use the media uploader - but I've not found any way to define/change where media are uploaded.
Is it possible to customize the download path? and if yes, how can it be done?
Thank you.
You can define the upload folder via the Settings --> Media or adding the following line in the wp-config.php:
define( 'UPLOADS', 'wp-content/'.'files' );

What is the way to upload bulk images in 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.

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 - How to change thumbnail size on Homepage? Can't find reference

I've searched throughout and can't find where to change the base thumbnail size on the Homepage (www.tomcpalead.com). It's set to 210 x 158. I change the Functions.php and nothing updates on the Homepage. Can't find the reference in style.css to edit it either.
Can someone help?
Thanks
The size of your thumbnails seems to be coming from here:
http://tomcpalead.com/?custom-css=1&csblog=1&cscache=6&csrev=4
I haven't seen CSS files named like that before though, so I'll defer to others who will have a better idea of where that's coming from. If there's any setting somewhere in your theme that looks like the following then that is what I would try editing:
.river .thumb img{width:16rem;height:9.75rem}
Just go to wordpress admin and follow this path :
Go to admin => Settings => Media
here, you will get the thumbnail size for all the images defined. You can change it as per your choice.
After modifying size, just check it by uploading a new image and set it a thumbnail image.

Resources