Tag Info

Hot answers tagged

4

WP sanitize_file_name() function doesn't handle those characters by default. You can add filter and sanitize those to avoid encoding issues. function mamaduka_sanitize_file_name( $filename ) { $filename = strtr($filename, ...


2

You can try the image_send_to_editor filter: /** * Wrap the inserted image html with <figure> * if the theme supports html5 and the current image has no caption: */ add_filter( 'image_send_to_editor', function( $html, $id, $caption, $title, $align, $url, $size, $alt ) { if( current_theme_supports( 'html5' ) && ! ...


2

First you need to get your attached image ID, how you get it depends on how you're setting the image. The generic idea is that you get the attachment ID then you can simply use get_the_title( $attachment_id ). If you're setting it as a Featured Image ( Post Thumbnail ) then you can use the following function to get the image ID: get_post_thumbnail_id( ...


1

I can tell how to do it with WordPress functions, which is quite easy and you won't lose any important stuff: Upload the default.jpg image using WordPress media manager. Note the ID of the image. Get all posts from your custom post type and run set_post_thumbnail() for each one. Example: add this code to functions.php of your theme or in a plugin. Visit ...


1

The code you provided could cause issues with 3rd party URLs in hyperlinks not running https. You can fix this by including your home url, e.g: $content = str_replace( set_url_scheme( home_url(), 'http' ), set_url_scheme( home_url(), 'relative' ), $content); Next, you're applying this when you'd like to display the content, which means you need to do an ...


1

yes, the naming convention for resized images is name-{width}x{height}.extension. Is it good enough info to base a regex on? in practice most likely yes, but in theory no. You just can't know if mark-20x20.jpg was not simply uploaded that way, and even in places where you know that a resized image should be used you have no way to know if wordpress had ...


1

You can use "rilwis/meta-box " for this . For dynamic slider use this snippet, <?php $images = rwmb_meta( 'gallery', 'type=image' ); foreach ( $images as $image ) { echo "<a href='{$image['']}' title='{$image['title']}' rel='thickbox'><img src='{$image['full_url']}' alt='{$image['alt']}' /></a>"; } ...



Only top voted, non community-wiki answers of a minimum length are eligible