New answers tagged

1

Since 3.7 there is a filter to change the width of the wrapping div directly. This will fix the extra 10px, and won't let the caption extend past the width of the image (unlike width: auto !important). function wp456_img_caption_width( $width, $atts, $content){ //by default 10 is added if image caption return $width - 10; } add_filter( '...


0

Sounds like you might already have your answer but I strongly recommand you to use DBSR (db search replace) to replace ALL occurrences of domain1 by domain2. There are tools for that. This one is pretty clean : https://github.com/interconnectit/Search-Replace-DB The whole process is described. There is a good UI. This way you'll be sure everything is ok ...


0

Try deactivating the plugin "Login-Log". That worked for me. If thats not it just disable all plugins and see if that helps. If so you just have to test which one brakes grid view for you.


1

Here's one way to inject the custom field as the featured image caption with help of the post_thumbnail_html filter: add_filter( 'post_thumbnail_html', function( $html, $post_id ) { if( $html && $caption = get_post_meta( $post_id, 'wpcf-bildunterschrift', true ) ) $html .= sprintf( '<p>%s</p>', esc_html( $caption ) ); ...


0

We can use simply https://wordpress.org/plugins/find-posts-using-attachment/ I hope it is the best way!


0

WordPress uses that when it resizes images to set the quality, but it will not go back and resize images it's already processed. If it did, your site would be continuously checking your uploads and grind to a halt You have these choices: Delete your attachments and reupload them Use a tool such as the regen thumbnails plugin to recreate the images ( will ...


0

I am proud to announce that I have found the solution thanks to @cjbj good advice. I paste the code here. I know it will help others. In addition, I used the function preg_quote to protect the path to the image. protected_path = preg_quote($filename); This code works great. // $filename should be the path to a file in the upload directory. $...


1

image_make_intermediate_size was not the hook I was looking for, but intermediate_image_sizes_advanced. Here is a working code: function disable_upload_sizes( $sizes, $metadata ) { // Get filetype data. $filetype = wp_check_filetype($metadata['file']); // Check if is gif. if($filetype['type'] == 'image/gif') { // Unset sizes if ...


0

Since the file you send is base64 encoded, you will need to decode and save the result into a file at a temp directory. From there it is just a normal server side wordpress image manipulation and insertion of the relevant info into the DB, something that there are many examples for on this site. You should probably return the URL of the generated image in ...


1

currently there is no good tool for resizing animated gifs Resizing of animated gifs is supported by ImageMagick, which happens to be the default image library of WordPress. The only thing is WP doesn't support this filter in its default API to ImageMagick. Fortunately, it is possible to intercept image_make_intermediate_size, the hook that produces the ...


0

You need the generate_filename method of the image editor class. Like this: $filename = $img->generate_filename( 'resized', ABSPATH.'wp-content/uploads/resized-images/'); $image->save($filename); This will save the image, renamed originalname-resized, in the resized-images directory of the upload folder. This does not mean WordPress knows it is ...


0

The moment an image is inserted in a post, the hook image_send_to_editor is called. The input to the hook is the html and perhaps also a caption shortcode. Like this: [caption id="attachment_999" align="alignright" width="150"] <a href="http://www.example.com/wp-content/uploads/2016/06/my-image.jpg"> <img src="http://www.example.com/wp-content/...


1

By default, when you upload an image via the admin, it's metadata is added to the database, and that's how you can search through them in the media library etc. If you upload images via ftp then they won't appear in the DB so won't show up in the admin area. Use a plugin such as https://wordpress.org/plugins/media-from-ftp/ which will let you loop through ...


1

If you had for example, <img src="rdp_banner.jpg" id="logoimage"> You could just do... add_action('init','checkvisitcookie'); function checkvisitcookie() { if (isset($_COOKIE['firsttimevisit'])) {return;} setCookie('firsttimevisit','1',100*365*24*60*60); add_action('wp_footer','fadelogoout'); } function fadelogoout() { echo "<...


3

Gallery Image Caption - As Title Of The Post It's attached To Here's one way to do it with a custom parent_titles attribute in the native gallery shortcode. This can be achieved by setting suppress_filters to false for the gallery query and modify the posts excerpts through the the_posts filter. We can then check for the custom attribute inputs through ...


0

The most elegant way is to use wp media regenerate. From the example: # re-generate all thumbnails, without confirmation wp media regenerate --yes


0

You don't give enough details but your image naming is just bad for wordpress. I am not sure if anywhere in core there is code that tries to detect a resolution by the filename suffix but it is a fragile and confusing habit. If you have to have the data in the name maybe use underscore instead.


0

The theme was auto generating alternative image sizes for responsiveness, so my newly named images were actually duplicates. Leaving this up in case anyone makes same mistake and stumbles across this.



Top 50 recent answers are included