OK, thank you, Phil. I am a novice at .php and I've crashed my site before pasting in code.
Do I need }'s before and after the code?
sorry to be so dense but there it is!
thanks again!
OK; omg well I'm a total dummy.
I pasted the code exactly as above, and it broke my site. The error message I get is:
Parse error: syntax error, unexpected '<' in /home/elucia/public_html/blog/wp-content/themes/BuilderChild-Scooter/functions.php on line 82
so, I remove the " ?>" and I also tried removing just the ">" and still not working; I get the same error code and site goes poof.
I've pasted the original functions.php code back in and the site is back to normal.
The code at the very end of my functions.php file (before I try pasting in the above code) looks like this:
`}
$sizes = array( $_ithemes_temp_downsize_size => $sizes[$_ithemes_temp_downsize_size] ); // Strip out all extra meta data so only the requested size will be generated.
return $sizes;
}
}
?>`
Where/how would I paste the code I need so I don't break the site?
thanks so much for your patience!
ok so still not working; I've tried ten different ways and places to paste this code into my functions.php...any clues at all to what I am doing wrong??
<?php
// Adding Theme Support for Post Thumbnails
if ( function_exists( 'add_theme_support' ) ) {
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 150, 150 ); // default Post Thumbnail dimensions
}
// Creating Custom Thumbnail Sizes
if ( function_exists( 'add_image_size' ) ) {
add_image_size( 'magazine-thumb', 100, 100, true ); //300 pixels wide (and unlimited height)
}
// Loading '/lib' Files
require_once('lib/outer-wrapper.php'); // Moves the classes from the inner wrapper to the outer wrapper
require_once('lib/alternate-modules.php'); // Adds alternate module styles
// Custom image resize function by iThemes.com. iTeration 19
if ( !function_exists( 'ithemes_filter_image_downsize' ) ) {
add_filter( 'image_downsize', 'ithemes_filter_image_downsize', 10, 3 ); // Latch in when a custom image size is called.
add_filter( 'intermediate_image_sizes_advanced', 'ithemes_filter_image_downsize_blockextra', 10, 3 ); // Custom image size blocker to block generation of thumbs for sizes other sizes except when called.
function ithemes_filter_image_downsize( $result, $id, $size ) {
global $_ithemes_temp_downsize_size;
if ( is_array( $size ) ) { // Dont bother with non-named sizes. Let them proceed normally. We need to set something to block the blocker though.
$_ithemes_temp_downsize_size = 'array_size';
return;
}
// Store current meta information and size data.
global $_ithemes_temp_downsize_meta;
$_ithemes_temp_downsize_size = $size;
$_ithemes_temp_downsize_meta = wp_get_attachment_metadata( $id );
if ( !is_array( $imagedata = wp_get_attachment_metadata( $id ) ) ) { return $result; }
if ( !is_array( $size ) && !empty( $imagedata['sizes'][$size] ) ) {
$data = $imagedata['sizes'][$size];
// Some handling if the size defined for this size name has changed.
global $_wp_additional_image_sizes;
if ( empty( $_wp_additional_image_sizes[$size] ) ) { // Not a custom size so return data as is.
$img_url = wp_get_attachment_url( $id );
$img_url = path_join( dirname( $img_url ), $data['file'] );
return array( $img_url, $data['width'], $data['height'], true );
} else { // Custom size so only return if current image file dimensions match the defined ones.
global $_wp_additional_image_sizes;
if ( ( $_wp_additional_image_sizes[$size]['width'] == $data['width'] ) && ( $_wp_additional_image_sizes[$size]['height'] == $data['height'] ) ) { // Only return if size hasnt changed.
$img_url = wp_get_attachment_url( $id );
$img_url = path_join( dirname( $img_url ), $data['file'] );
return array( $img_url, $data['width'], $data['height'], true );
}
}
}
require_once( ABSPATH . '/wp-admin/includes/image.php' );
$uploads = wp_upload_dir();
if ( !is_array( $uploads ) || ( false !== $uploads['error'] ) ) { return $result; }
$file_path = "{$uploads['basedir']}/{$imagedata['file']}";
// Image is resized within the function in the following line.
$temp_meta_information = wp_generate_attachment_metadata( $id, $file_path ); // triggers filter_image_downsize_blockextra() function via filter within. generate images. returns new meta data for image (only includes the just-generated image size).
$meta_information = $_ithemes_temp_downsize_meta; // Get the old original meta information.
if ( array_key_exists( 'sizes', $temp_meta_information ) ) {
$meta_information['sizes'][$_ithemes_temp_downsize_size] = $temp_meta_information['sizes'][$_ithemes_temp_downsize_size]; // Merge old meta back in.
}
wp_update_attachment_metadata( $id, $meta_information ); // Update image meta data.
unset( $_ithemes_temp_downsize_size ); // Cleanup.
unset( $_ithemes_temp_downsize_meta );
return $result;
}
/* Prevents image resizer from resizing ALL images; just the currently requested size. */
function ithemes_filter_image_downsize_blockextra( $sizes ) {
global $_ithemes_temp_downsize_size;
if ( empty( $_ithemes_temp_downsize_size ) || ( $_ithemes_temp_downsize_size == 'array_size' ) ) { // Dont bother with non-named sizes. Let them proceed normally.
return $sizes;
}
$sizes = array( $_ithemes_temp_downsize_size => $sizes[$_ithemes_temp_downsize_size] ); // Strip out all extra meta data so only the requested size will be generated.
return $sizes;
}
}
?>
Founder & CEO
—
11th October 2011 (7 months ago)
#
Hi Elucia,
As we haven't heard back from you we're going to assume the problem was sorted out and mark this thread as resolved.
If it wasn't resolved, or you have any more questions related to this thread please feel free to post them below and tick the 'Mark as Not Resolved (re-open)' box below the post area (or else we'll miss it!)
Otherwise, thanks for using the forums, and, as always, for being a member of WPMU DEV, it's a pleasure to help you out and we look forward to being of assistance in the future.
Hi James
thank you for following up.
No, it didn't work, and I had spent so much time on it that I had to stop and move on to other things. I never was able to use the Q and A plugin...I just gave up.
If I remember correctly, for ME the plugin is difficult to style...integrating it into my site is the goal, and I can't see having to spend so much time on coding php to get a plugin to look, as well as function, as I need. That's why I BUY plugins. It would be great if the plugin had built-in styling features that do not require php coding.
ANYWAY:
I really DO want to use it so maybe I will give it another try with the plugin upgrade.
thank you for the follow up.
Elaine
Responses (10)
Sales & Support Pro — 17th August 2011 (9 months ago) #
Hiya!
The short answer is anywhere.
It doesn't really matter where it goes so long as it isn't inside another function or class....
Phil
Member — 17th August 2011 (9 months ago) #
OK, thank you, Phil. I am a novice at .php and I've crashed my site before pasting in code.
Do I need }'s before and after the code?
sorry to be so dense but there it is!
thanks again!
Sales & Support Pro — 17th August 2011 (9 months ago) #
Nope, the exact snippet you posted in your original message is all you need :)
Don't worry, we've all been there!
Phil
Member — 17th August 2011 (9 months ago) #
OK; omg well I'm a total dummy.
I pasted the code exactly as above, and it broke my site. The error message I get is:
Parse error: syntax error, unexpected '<' in /home/elucia/public_html/blog/wp-content/themes/BuilderChild-Scooter/functions.php on line 82
so, I remove the " ?>" and I also tried removing just the ">" and still not working; I get the same error code and site goes poof.
I've pasted the original functions.php code back in and the site is back to normal.
The code at the very end of my functions.php file (before I try pasting in the above code) looks like this:
`}
$sizes = array( $_ithemes_temp_downsize_size => $sizes[$_ithemes_temp_downsize_size] ); // Strip out all extra meta data so only the requested size will be generated.
return $sizes;
}
}
?>`
Where/how would I paste the code I need so I don't break the site?
thanks so much for your patience!
Member — 17th August 2011 (9 months ago) #
ok so still not working; I've tried ten different ways and places to paste this code into my functions.php...any clues at all to what I am doing wrong??
thanks!!
Sales & Support Pro — 18th August 2011 (9 months ago) #
Can you post your entire functions.php please?
Member — 18th August 2011 (9 months ago) #
yes, thank you! here it is:
Sales & Support Pro — 18th August 2011 (9 months ago) #
Okay, add this at the end, just before the "?>" bit;
add_theme_support('qa_style');Phil
Founder & CEO — 11th October 2011 (7 months ago) #
Hi Elucia,
As we haven't heard back from you we're going to assume the problem was sorted out and mark this thread as resolved.
If it wasn't resolved, or you have any more questions related to this thread please feel free to post them below and tick the 'Mark as Not Resolved (re-open)' box below the post area (or else we'll miss it!)
Otherwise, thanks for using the forums, and, as always, for being a member of WPMU DEV, it's a pleasure to help you out and we look forward to being of assistance in the future.
Cheers, James
Member — 11th October 2011 (7 months ago) #
Hi James
thank you for following up.
No, it didn't work, and I had spent so much time on it that I had to stop and move on to other things. I never was able to use the Q and A plugin...I just gave up.
If I remember correctly, for ME the plugin is difficult to style...integrating it into my site is the goal, and I can't see having to spend so much time on coding php to get a plugin to look, as well as function, as I need. That's why I BUY plugins. It would be great if the plugin had built-in styling features that do not require php coding.
ANYWAY:
I really DO want to use it so maybe I will give it another try with the plugin upgrade.
thank you for the follow up.
Elaine
Become a member