Getting a specific value out of array using get_attached_media

Don’t use the GUID. Despite appearances, that isn’t an URL. Use wp_get_attachment_image_src. Something like: $image = wp_get_attachment_image_src($post_id,’full’); echo $image[0]; Or use wp_get_attachment_url with the post ID. $image = wp_get_attachment_url($post_id); Of course, I don’t know what the actual variable name is that holds your images but you should see the ID in the post objects and … Read more

How can I modify the media upload form fields?

Would maybe look into do_action( ‘pre-upload-ui’ );. Here is my first thoughts, please note it’s not tested but should get you in the right direction. add_action( ‘pre-plupload-upload-ui’, ‘sd_extra_info’ ); function sd_extra_info() { # see wp-includes/media-template.php print ‘<pre> Some more info here </pre>’; }

Redirect Attachment Page to Attachment

You can’t redirect after content has already been sent to the browser, hook an action before the template is loaded and do your redirect there. function wpa_attachment_redirect(){ if( is_attachment() ){ // your code and redirect here } } add_action( ‘template_redirect’, ‘wpa_attachment_redirect’ );

WordPress import media error

Admittedly, this is a guess. The exporter, in the versions I have used, does not save your files to a local disk. It creates an XML file with references to your images on a server somewhere. When the importer reads the XML file, it will download from that server and upload to your new installation. … Read more

Media/attachment urls don’t redirect with fake URL structure

Milo got me on the right track. If anyone else happens to have this issue the code I used is: /** * Redirect broken attachment links to 404 */ function ww_404_broken_links(){ global $wp_query; if(is_attachment()){ $attachment_path = get_attached_file( get_the_ID() ); //If the file doesn’t exist on the server show 404 if(!file_exists($attachment_path)){ $wp_query->set_404(); status_header( 404 ); get_template_part( … Read more

How To Pick Custom Size Of Uploaded Image In Theme Via the_post_thumbnail();?

You can use add_image_size() function to create custom sized images. You only need to paste some piece of codes in your functions.php and then update the template files accordingly. For example : add_image_size( ‘category-thumb’, 300 ); // 300 pixels wide (and unlimited height) add_image_size( ‘homepage-thumb’, 220, 180, true ); // (cropped) And you can use … Read more

Limit dimensions of “Full” size images

So I’ve found this WP_Image_Editor in the CodeX. Basically by adding the code below it should automatically resize an image 🙂 Code: $image = wp_get_image_editor( ‘cool_image.jpg’ ); // Return an implementation that extends WP_Image_Editor if ( ! is_wp_error( $image ) ) { $image->resize( 300, 300, true ); $image->save( ‘new_image.jpg’ ); } I don’t know exactly … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)