Image thumbnails not available post migration, but still accessible via direct URL – DB issue

Domain change This kind of error may be caused by wrong host name in image urls that are stored in the database. It is necessary to replace strings holding your old domain with new one: http://olddomain.com –> http://newdomain.com In every migtration process I use the following recommended tool: https://interconnectit.com/products/search-and-replace-for-wordpress-databases/ Upload it to your WP root … Read more

WooCommerce-like featured gallery

I found a solution to this. I am using the plugin (No UI) Metabox that has this feature by default. This is the code i used to achieve my desired result: add_filter( ‘rwmb_meta_boxes’, ‘prefix_register_meta_boxes’ ); function prefix_register_meta_boxes( $meta_boxes ) { $prefix = ‘rw_’; $meta_boxes[] = array( ‘title’ => ‘Media’, ‘pages’ => array( ‘bestilling’), ‘fields’ => … Read more

How to display multiple images in custom field

Assuming we are viewing some king of single – post, page, custom post type etc. <?php $imgs_meta = get_post_meta( get_the_ID(), ‘AP_post_image’, true ); if ( ” != $imgs_meta ) { $imgs = explode( ‘,’, $imgs_meta ); foreach ( $imgs as $src ) printf( ‘<img src=”https://wordpress.stackexchange.com/questions/182602/%s” />’, esc_url( $src ) ); }

Understanding and altering the structure of posted images

Lets start with your first code. If you add texts, captions etc. a shortcode will be generated: The function img_caption_shortcode() in wp-content/media.php is responsible to execute the shortcode. But this shortcode is only produced, when you use captions. Otherwise, it will be simply inserted the <a>– and <img>-Tag. who decides, what gets inserted? There is … Read more

How to display / include a specific jpg on a page

To load images from the location you currently have them stored use get_site_url() to generate a path: $a = date(‘md’).”.jpg”; $a = get_site_url(null,’images/’.$a); // var_dump($a); Then use that information to create an img tag. I would recommend loading the images from a theme folder, if this is part of a particular theme. If that is … Read more

How to make a local cache of mshots images

I think this should work. function upload_image_from_url($url) { /** Require dependencies */ require_once( ABSPATH . ‘wp-admin/includes/image.php’ ); require_once( ABSPATH . ‘wp-admin/includes/file.php’ ); require_once( ABSPATH . ‘wp-admin/includes/media.php’ ); // Save as a temporary file $tmp = download_url( $url ); // Check for download errors if ( is_wp_error( $tmp ) ) { @unlink( $file_array[ ‘tmp_name’ ] ); … Read more

Output random (custom) image size

I don’t think there exists such function in the WordPress core. Example #1 But you can try something like this: /** * Random image size * @return String Image size */ function wpse_random_image_size() { $sizes = (array) get_intermediate_image_sizes(); return $sizes[array_rand( $sizes )]; } to display a random image size. Usage: if ( function_exists( ‘wpse_random_image_size’ ) … Read more