Disabling auto-resizing of uploaded images

To disable resizing for all image sizes without manually removing each size with remove_image_size function, use the filter intermediate_image_sizes_advanced /** * @param array $sizes An associative array of image sizes. * @param array $metadata An associative array of image metadata: width, height, file. */ function remove_image_sizes( $sizes, $metadata ) { return []; } add_filter( ‘intermediate_image_sizes_advanced’, … Read more

How to default all users to no link for attachments?

This is the final non-JS method that finally worked for me: Step 1: update sitewide option You can do this several ways. Since setting it is a one-time operation, I opted to update this by visiting https://www.example.com/wp-admin/options.php . I searched for “image_default_link_type” and set it to “none” (the word none, not null), then saved the … Read more

Crop image without scaling or resizing with add_image_size()

You cant do that with the add_image_size() function, after a lot of research and digging in the core files, what the Hard Crop option of the add_image_size() function actually does is resize the image using the lower dimension, then it will crop the size specified by example if you create a new image size: add_image_size( … Read more

Link to File URL by default

Answered a similar question on the .org forums very recently. To sum it up though.. Go to http://example.com/wp-admin/options.php (replace example.com with your website address) Scroll down the page until you see image_default_link_type Set that option to either file, post or to an empty value. Empty = No link File = Links to the file(what you … Read more

Displaying a featured image (only img url) as the img src?

Here are the functions you need to be aware of: http://codex.wordpress.org/Function_Reference/get_post_thumbnail_id http://codex.wordpress.org/Function_Reference/wp_get_attachment_url http://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src http://codex.wordpress.org/Function_Reference/wp_get_attachment_image Example sans size: echo wp_get_attachment_url(get_post_thumbnail_id()); Example with size: $image = wp_get_attachment_image_src(get_post_thumbnail_id(), ‘large’); echo $image[0]; //as HREF in your A tag You can grab all of the gallery images as follows: $args = array( ‘order’=> ‘ASC’, ‘post_mime_type’ => ‘image’, ‘post_parent’ => $post->ID, … Read more

Can’t Display Featured Image in RSS Feed

By default, RSS won’t display. You have to use RSS2. However this will help you. Paste it in your functions.php: function insert_thumbnail_into_feed() { global $post; if ( has_post_thumbnail( $post->ID ) ){ // replace thumbnail with yours $content=”<p>” .get_the_post_thumbnail( $post->ID, ‘thumbnail’ ) .'</p>’; } // get post content and replace feed content with // you can … Read more

how to base64 encode images in wordpress template

in your file functions.php in your template put this funcitons /** * @param $path * @return string * @author https://github.com/ozzpy */ function imageEncode($path) { $path = __DIR__.”https://wordpress.stackexchange.com/”.$path; $image = file_get_contents($path); $finfo = new finfo(FILEINFO_MIME_TYPE); $type = $finfo->buffer($image); return “data:”.$type.”;charset=utf-8;base64,”.base64_encode($image); } /** * @param $path * @return string * @author https://github.com/ozzpy */ function imageEncodePath($path) { $image … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)