Overwriting Parent Theme’s Image Sizes
No need for the filter. You can just call add_image_size later than the parent & it will overwrite.
No need for the filter. You can just call add_image_size later than the parent & it will overwrite.
No, images are global and you might change which content they are associated with at which point you will need sizes that do not exist. You can generate images “on the fly” but this may slow down page generation (depending on the way generated image information is cached) and might break code which “pushes” into … Read more
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
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
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 ) ); }
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
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
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
I found that what was causing this issue was a plugin I had enabled that was supposed to handle retina images called WP Retina 2X. I disabled the plugin and it immediately fixed the issue.
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