Tag Info

New answers tagged

0

OK so I figured it out, I'm sure they're much more elegant ways of doing this but it works for what I needed to do. <?php // Single Audio & Playlist player global $post; $args = array( 'post_parent' => $post->post_parent, 'numberposts' => -1, 'post_status' => 'null', ...


2

Some ideas for your attachments file: A simplification: $tmp = $post; // Store the current global post object $post = get_post( $post->post_parent ); // Use the post parent post object $media = get_attached_media( 'audio' ); if( $media ) { $sc = "[audio]"; if( count( $media ) > 1 ) { $ids = join( ',', ...


0

I was doing something similar the other day and simply could not get attachment_fields_to_save to work no matter what I tried. I ended up using the edit_attachment filter instead along with code like the following: public function action_edit_attachment( $attachment_id ) { # Check to make sure we were sent by the side of the media editor, not by the ...


2

You can try the following example, for image attachments: add_action( 'init', function() { add_rewrite_endpoint( 'download', EP_ROOT ); add_action( 'template_redirect', function() { if ( $pid = get_query_var( 'download' ) ) { $found = false; ...


2

You're on the right path with a rewrite rule. If you're just delivering a file, you can hook an early action, check if a download was requested, then output the file and exit before WordPress ever gets to the stage of querying the database and deciding the request is a 404. // add the download ID query var which we'll set in the rewrite rule function ...


3

I wonder if you want to modify the HTML of the inserted image, with the image_send_to_editor or get_image_tag filters? If that's the case, then here's one example: /** * Add the data-ext-link-title and data-ext-link-url attributes to inserted images. */ add_filter( 'image_send_to_editor', function( $html, $id, $caption, $title, $align, $url, ...


0

I've figured out a solution, here is my answer 1, we can't modify Wordpress original data input, but we can modify and rewrite the output. So we can use the_content,wp_get_attachment_url to change this. add this code snippets into your plugins if (function_exists('add_filter')) { add_filter('the_content', array($scplugin, ...


0

I've struggled with the same thing pretty much always. There's a plugin called File Un-Attach, and a Unattach and Re-attach Media Attachments. See if they work for you. There's also 5 year old Trac ticket on this, but it seems to be under conversation still.


1

Maybe you have an image that was smaller or equal to the thumbnail size, if so, then no thumbnail will be created, and this.data[i].sizes.thumbnail will be undefined.


0

wp_get_attachment_image_src returns an array with 3 elements; the image URL, the width, and the height. You need to echo the first index of the result. In fact, you can make your code a little leaner by using a foreach loop: foreach ( $images as $i => $image ) { $src = wp_get_attachment_image_src( $image->ID, 'full' ); echo '<img ...


1

The Image added by Add Media is included in the Content.So I have splitted the image from the content.Below is the working code for my Question. <?php $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches); ?> <div class ="single-post-flex-slider"> <ul class="slides"> <?php ...


0

In a normal post when you add an image, the WordPress editor adds the title to the img tag, not to the surrounding a tag. If both tags had different titles the title of the img tag would be displayed by the browser, not the title of the a tag. Using your original example, I have added a title attribute to the img tag: <a href="path_to_files/image.jpg" ...



Top 50 recent answers are included