WordPress image crop probems

You don’t need to do manual cropping; just create a custom image size, and WordPress will perform the cropping on image upload. e.g. in functions.php: add_image_size( ‘portfolio-thumbnail’, 214, 187, true ); Then in your portfolio template, inside the Loop: the_post_thumbnail( ‘portfolio-thumbnail’ ); (I assume you know how to handle the rest of the output, such … Read more

Images don’t update after being edited

When you upload an image via the media library, additional sizes are created: large, medium, thumbnail, plus any additional sizes defined by plugins or your theme. If your theme displays any sizes other than the original, un-resized image, you’ll have to regenerate those additional sizes to see any changes take effect. If this is the … Read more

How to modify the attachment info text on gallery tab or media page?

Add this to functions.php file. function image_attachment_field($form_fields, $post) { if( substr($post->post_mime_type, 0, 5) == ‘image’ ){ $user = new WP_User( $post->post_author ); $form_fields[“author”][“input”] = “html”; $form_fields[“author”][“html”] = ‘<p><strong>Author:</strong> ‘.$user->display_name.'</p>’; $form_fields[“license”][“input”] = “html”; $form_fields[“license”][“html”] = ‘<p><strong>License:</strong> GPL</p>’; $form_fields[“source”][“input”] = “html”; $form_fields[“source”][“html”] = ‘<p><strong>Source:</strong> BNS</p>’; } return $form_fields; } add_filter(“attachment_fields_to_edit”, “image_attachment_field”, null, 2); This will ONLY add … Read more

Conditional tag to determine if the user is viewing the Add Media (after clicking Add media button)

There are multiple actions available. Demo: add_action( ‘upload_ui_over_quota’, ‘wpse_78085_callback’ ); add_action( ‘pre-upload-ui’, ‘wpse_78085_callback’ ); add_action( ‘pre-plupload-upload-ui’, ‘wpse_78085_callback’ ); add_action( ‘post-plupload-upload-ui’, ‘wpse_78085_callback’ ); add_action( ‘post-upload-ui’, ‘wpse_78085_callback’ ); function wpse_78085_callback() { # see wp-includes/media-template.php print ‘<pre>’ . current_filter() . ‘</pre>’; } Result:

A link (not in the post) to download a specific PDF file

The pdf is itself an attachment post so in wordpress template hierarchy we can create a template named pdf.php Then you can write following code in it which force download the pdf file. <?php if (have_posts()) : the_post(); $pdf_title = $post->post_title; $pdf_src = get_attached_file($post->ID ); $bytes = filesize( $pdf_src ); header(“Pragma: public”); // required header(“Expires: … Read more

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