New answers tagged

0

May be this can help you. I am not writing in detail as I am not sure if it was the actual question. if ( ! function_exists( 'wp_handle_upload' ) ) { require_once( ABSPATH . 'wp-admin/includes/file.php' ); } //selected file to upload $uploadedfile = $_FILES['attachdoc']; //wp_handle_upload to upload the file. Check documentation. $upload_overrides = ...


1

Here you go: if(!current_user_can('delete_others_posts')){ /*Handling wp media uloads*/ add_filter('wp_handle_upload_prefilter','lets_handle_img_width'); function lets_handle_img_width($file) { $img = getimagesize($file['tmp_name']); $width = $img[0]; if ($width < 350){ $file['error'] = "Image is ...


0

hammered it out. Anyone else with this question, try <img src="<?php bloginfo('stylesheet_directory'); ?>/images/yourimagename.jpg">


0

WordPress generate some smaller images (the thumbnails) so, the images are on your server, but thumbnails are not. If the issue is just a thumbnail rebuild, you can do rebuild them with this plugin: https://wordpress.org/plugins/ajax-thumbnail-rebuild/ With lucky you will not need to do anything else. But thumbnails sizes are defined per theme, plugin or ...


0

You are using the Advanced custom fields plugin. The documentation for images: http://www.advancedcustomfields.com/resources/image/ To display the alt-tag for example, you can use this snippet: $image = get_field('image'); if( !empty( $image ) ) { $alt = $image['alt']; ... echo '<img src="..." alt=" . $alt .">' }


0

I would check the upload_path upload_url_path under your admin options. I suspect they are still referencing the other website. Go to https://yourdomain.com/wp-admin/options.php and scroll down till you get to the the upload_path and upload_url_path.


0

Here is a plugin that can accomplish that. https://wordpress.org/plugins/better-search-replace/ Just select wp_posts and wp_posts_meta, check the GUID box, and replace image/bmp with image/jpeg and .bmp with .jpg I changed 5000 images in about 20 seconds.


0

You could try preg_match() if ( preg_match( "/thisfolder/", $imageURL) ) { echo 'your url here'; } See more here: http://php.net/manual/en/function.preg-match.php


1

It looks like you use the Jetpack Plugin with Photon function (Wordpress.com photo CDN) https://jetpack.me/support/photon/ https://developer.wordpress.com/docs/photon/ You have to deactivate the Photon option in the Jetpack plugin settings.


1

So I've found this WP_Image_Editor in the CodeX. Basically by adding the code below it should automatically resize an image :) Code: $image = wp_get_image_editor( 'cool_image.jpg' ); // Return an implementation that extends WP_Image_Editor if ( ! is_wp_error( $image ) ) { $image->resize( 300, 300, true ); $image->save( 'new_image.jpg' ); } ...


0

The method I prefer to use is just a bit shorter then the previous answer. <php $myExcerpt = wp_trim_words( get_the_content(), 20, '' ) ; echo $myExcerpt ; ?> The WordPress function wp_trim_words() returns only text (no images). wp_trim_words ( string $text, int $num_words = 55, string $more = null )


0

I left out the = in <img src="... So the code should look like <img src="<?php echo get_post_meta( get_the_ID(), 'slide_one_image', true ); ?>" /> Thanks


0

You can edit the default image sizes that WordPress creates by going to Settings -> Media in your WordPress dashboard and specifying image sizes. However, this will change the default image sizes and will affect all images across your site. Another option is to edit the template file that is displaying your blog (likely home.php or index.php) using ...


2

Many thanks to Nathan Powell for the fix. Changing get_stylesheet_directory() to get_stylesheet_directory_uri() will return the correct URL. get_stylesheet_directory() returns the absolute server path to child or parent theme (hence my previous issue) whereas get_stylesheet_directory_uri() returns the properly formed URI of child or parent theme. I ...


0

When inserting images into posts and pages in WP 4.4, change the Link To under ATTTACHMENT DISPLAY SETTINGS to None.


5

This is more of a general srcset and browser question, not a WordPress specific question. However, in general, you can't predict what browsers will do with the srcset information. For your specific example, it appears that you failed to clear the cache completely between your reloads. Note the 304 response indicating that your browser already has the image ...


-2

You could remove it with jQuery this way: jQuery('.zoomthumbnail-image').next('br').remove();


2

This is sort of an alternative solution to doing a bunch of RegEx. Query all images attached to the post, get the thumbnail of the first and display it as thumbnail ( you could even assign it as the post thumbnail if you wanted to, to make it easier next time the loop is run ). So inside your loop you would have: if( have_posts() ) { $image_mimes = ...


0

With @jgraup 's help in comments, I had a look at the responsive images plugin linked there. While that particular one has several other filters on things like post content which I would have preferred not to use, the RespImg class included is exactly what I was wanting. I was originally considering what would be required to remove all the filters added by ...


0

Make sure you have the Text / HTML tab selected when you input HTML, not the Visual tab.


0

Wordpress supports quite a few embeds including YouTube since WordPress 2.9. To render anywhere, just pass your content through the_content filter and it should automatically convert the urls. $oembedContent = apply_filters( 'the_content', $basicContent ); If the defaults don't meet your needs you can add an oEmbed-Enabled site using ...


1

Register a new image size with add_image_size( $name, $width, $height, $crop ). // Hard crop left top add_image_size( 'custom-size', 160, 90, array( 'left', 'top' ) ); Then use a plugin like Regenerate Thumbnails which will automatically create the new sizes on your server. You can also make your custom sizes selectable from your WordPress admin. To do ...



Top 50 recent answers are included