How to change image url?

Go into your WordPress Dashboard > Settings > Media and then untick the option that says Organize my folders into Month and Year based folders This will make it look like: http://example.com/wp-content/uploads/imagename.jpg Then to take it further you need to update you config.php file and add in either this line: define( ‘UPLOADS’, ‘image/’.’files’ ); This … Read more

get custom image size

If you know the image’s ID : wp_get_attachment_image( $image->ID, array(200, 112) ); returns an HTML img element or empty string on failure. The entire code could be something like : <a href=”https://wordpress.stackexchange.com/questions/170690/<?= get_attachment_link(“5435′ ); ?>”> <?= wp_get_attachment_image( ‘5435’, array(200, 112) ); ?> </a>

Display an image instead of tag name?

A clean and semantic way to do it would be with CSS. First, the PHP: <div class=”entry-meta”> <span class=”term-links”> <?php foreach ( get_the_terms( $post->ID, ‘region’) as $term ) : ?> <a href=”https://wordpress.stackexchange.com/questions/233793/<?php echo esc_url( get_term_link( $term->term_id ) ) ?>”>Region: <span class=”<?php echo $term->slug ?>”><?php echo $term->name ?></span></a> <?php endforeach; ?> </span> </div> Next, the CSS: … Read more

Rename image file by post title

I think what you’re looking for is the filter: wp_handle_upload_prefilter. From the Codex: The single parameter, $file, represent a single element of the $_FILES array. The wp_handle_upload_prefilter provides you with an opportunity to examine or alter the filename before the file is moved to its final location. Example code from the Codex: add_filter(‘wp_handle_upload_prefilter’, ‘custom_upload_filter’ ); … Read more

Get full image array

The “full array” is constructed by Advanced Custom Fields from various sources. It’s not a format that occurs natively in WordPress. If you want to output an image tag for an image with all the correct attributes, just use the ID with wp_get_attachment_image(). That returns an HTML <img> tag with the src, width, height, alt, … Read more

hardcrop images in gutenberg “latest posts” block

The Latest Posts block uses (wp.data.select( ‘core/block-editor’ ).getSettings() to get) the image sizes in the editor settings which can be filtered via the block_editor_settings hook in PHP: apply_filters( ‘block_editor_settings’, array $editor_settings, WP_Post $post ) Filters the settings to pass to the block editor. And the setting name used for the image sizes is imageSizes. So … Read more