livingsmarttv,
Yes it is possible to not crop and only scale images. It gets a bit tricky with this theme though because it is set to crop every image(except the featured.)
In the functions.php file, you will find somewhere around line 320:
//featured image
$td_crop_features_image = td_util::get_option('tds_' . 'crop_features_image');
if ($td_crop_features_image == '') {
add_image_size('featured-image', 700, 0, true);
} else {
add_image_size('featured-image', 700, 357, true);
}
//the small thumbnails
set_post_thumbnail_size( 100, 65, true );
add_image_size('art-thumb', 100, 65, true);
//small height, 1 col wide
add_image_size('art-wide', 326, 159, true);
//medium height 1 col wide
add_image_size('art-big-1col', 326, 235, true);
//the slides
add_image_size('art-slide-small', 326, 406, true);
add_image_size('art-slide-med', 700, 357, true);
add_image_size('art-slide-big', 1074, 483, true);
//big slider - big image
add_image_size('art-slidebig-main', 745, 483, true);
//the gallery
add_image_size('art-gal', 210, 210, true);
Notice that TagDiv has built in the ability to turn cropping on or off on the featured image based on a setting in the theme panel, but you are asking for all of them.
add_image_size('featured-image', 700, 0, true);
In the line above, it is the ‘0’ argument that tells wordpress to adjust the height based on the aspect ratio of the image after it is scaled. To analyze the code a little more, what is happening with the ‘featured-image’ image size is that if them theme is not set to crop option then the ‘featured-image’ will be scaled to 700px wide and left to be however tall the image is. If you select the crop option, it will be scaled to 700px wide and then cropped to 357px tall.
You would need to look at which block(s) you are using and then determine which module the block is using to tell what image size it is. For example, let’s say your block uses td_module_2.php.
In that file, line 13 reads: <?php echo $this->get_image('art-big-1col'); ?>
If we look above at the functions.php entry, we see: add_image_size('art-big-1col', 326, 235, true); This means that if you upload a 1280×720 image, this will resize it’s width and crop it’s height to 235 pixels. If the scaled down image height is less than 235px tall, then it will scale the height to 235px and crop the width to 326px. This is not what you want. Rather, perhaps something like this: add_image_size('art-big-1col', 326, 0, false); This will take the image and scale to 326px wide and let the height be what it will be.
If you want make these changes so that updates to the theme will not break it, then you need to copy the image size declarations out of the theme’s functions.php file and put them in your child theme’s functions.php file and change the options. You might try something like this:
//featured image
$td_crop_features_image = td_util::get_option('tds_' . 'crop_features_image');
if ($td_crop_features_image == '') {
add_image_size('featured-image', 700, 0, false);
} else {
add_image_size('featured-image', 700, 357, false
}
//the small thumbnails
set_post_thumbnail_size( 100, 0, false );
add_image_size('art-thumb', 100, 0, false);
//small height, 1 col wide
add_image_size('art-wide', 326, 0, false);
//medium height 1 col wide
add_image_size('art-big-1col', 326, 0, false);
//the slides
add_image_size('art-slide-small', 326, 0, false);
add_image_size('art-slide-med', 700, 0, false);
add_image_size('art-slide-big', 1074, 0, false);
//big slider - big image
add_image_size('art-slidebig-main', 745, 0, false);
//the gallery
add_image_size('art-gal', 210, 0, false);
By setting all the height arguments to 0, we tell WordPress to always use the full height of an image relative to the horizontal scaling and by changing ‘true’ to ‘false’ we enable ‘soft crop mode’ vs ‘hard crop mode.’ Soft crop mode ensures your images will maintain their aspect and not have any cropping. Note, the 0 setting will make it so that any image uploaded that is not 16×9 aspect will be scaled and output at it’s own aspect ratio. This can break styling, but if you only upload 16×9 images it will be fine.
You would need to either re-build your current thumbnails or upload some new images to see if this fixes your problem(or creates others)
There are lots of gotchas here, and I certainly didn’t give you a definitive answer, but perhaps what I did say will help you figure out what combination of options will solve your problem.
Good luck!
The way this theme handles css is far from straightforward(not that there’s anything wrong with that!) It loads 2 different css files (3 if you have a child theme) as well as inlining a ton of styles from the Theme Panel in the header or footer depending on if you have the td_speed_booster plugin installed.
Depending on your Layout setting in the Theme Panel it will first load one of these files: td-bootstrap.css, td-bootstrap-980-not-resp.css, td-bootstrap-980-responsive.css or td-bootstrap-1170-not-resp.css. These are all compiled by TagDiv manually, using some combination of the Less files found in /Newspaper/includes/wp_booster/external/bootstrap/bootstrap-master/less.
If you have a child theme, it’s style.css will load next.
After that, it will load the theme style.css, which is compiled by TagDiv from the Less files located in /Newspaper/less_files.
The last step is to inline all of the styles that are defined in the Theme Panel. This is handled by 3 files, td_css_buffer.php, td_css_compiler.php and td_css_generator.php which are located in /Newspaper/includes/wp_booster. The td_css_generator.php file is where the Theme Panel option rules are hard-coded, the td_css_generator gets the settings from the Theme Panel and sends them to the compiler which then pushes the compiled styles to the td_css_buffer which writes them in the <head> or to the the td_speed_booster which loads them somewhere between the closing #outer-wrap </div> and </body>.
The theme has an on-the-fly compiler that can be used with the Less files in the less_files directory, you just go into /Newspaper/includes/wp_booster/td_config.php and set the Deploy Mode to dev instead of deploy. This will replace the theme’s style.css with the output of the less compiler.
This is problematic though, because this is only for development and once you have edited your styles, you cannot use that compiler to create a new style.css file to replace the old one(it outputs errors). You have to use a different compiler to get your final css file, because you can’t use the live compiler in production. This also does not affect the bootstrap or the hard-coded Theme Panel styles.
I’m using IDEA13 with the Less plugin and I can compile the main.less into a style.css that replaces the default one just fine, however I have not been able to do the same with the td-bootstrap.css. I need to figure out what magic combination of files in the bootstrap Less files will output the same td-bootstrap.css file that ships with the theme. Perhaps one of the TagDiv guys can shed some light on how that file is compiled?
I am using 3.3 and I can confirm that shortcodes do not work for me in the visual editor if I use a Raw HTML Element. They do work if I use a Text Block.
That probably won’t work though, because the plugin is most likely coded to return $content and not $buffy…
That’s all I got. Good luck!
In that case, perhaps a different approach. Add your own hook and change the plugin to call later
In your td_module_1, you could add a hook. Change $buffy .= $this->get_content();
To this:
$buffy .= $this->get_content();
my_after_content_hook($buffy);
Then in your plugin files, you need to find the add_filter( 'the_content', 'the_plugin_function_name', $priority); and change it to add_filter( 'my_after_content_hook', 'the_plugin_function_name', $priority);
-
This reply was modified 12 years by
webmaster808.
-
This reply was modified 12 years by
webmaster808. Reason: Need to modify $buffy with the filter, not $content
Yeah, the_content() doesn’t understand $this->get_author_box().
Does this work?
function my_td_authorbox($content){
global $post;
$content .= get_author_box($post->ID);
return $content;
}
Ahh, the plot thickens…
Most likely your social plugin is using add_filter() to add their output to the end of the_content();
In that case, I think you would you would need to do something like this in your functions.php
// Filter the_content BEFORE the plugin does, this is by setting the priority argument, which is represented by the X. Need to make sure that number is higher than the one that the plugin uses to add their filter
add_filter( 'the_content', 'my_td_authorbox', X );
function my_td_authorbox($content){
// Not sure if $this will work in this context, just have to see.
$content .= $this->get_author_box();
return $content;
}
Well, as far as I can tell you are using module 1, which is the default module for single posts.
If that is true then making the edits that I suggested in wp-content/themes/Newspaper/includes/modules/td_module_1.php would do exactly what you want. How are you editing these files?
One way we can check to see what module is being loaded is to echo the variable.
On line 94 of your single.php file change <?php to <?php echo $loop_module_id;
Then, just inside the container div on your post you should see a single digit and that is the module number that is being called.
are you using the child theme?
I’ve got to head out for about an hour. I can help more when I get back.
Ok, I’m sorry I didn’t pick up on the fact that you are trying to do this from the Theme Panel.
There is no way for you to change that in the Theme Panel(or anywhere in the wordpress admin). That is something that requires modification of the theme itself. The theme does not have an option for you to choose where to put the author box.
The instructions that I gave are for modifying the files that exist on your server.
Assuming you are using module 1, you would edit your includes/modules/td_module_1.php file.
Find the section of code that looks like this(mine starts at line 49):
if ($this->show_excerpt === true) { //module 7 uses this
$buffy .= '<p>' . $this->get_excerpt(td_util::get_option('tds_' . 'mod7_content_excerpt')) . '</p>';
$buffy .= '<div class="more-link-wrap wpb_button td_read_more clearfix">';
$buffy .= '<a href="' . $this->href . '">' . __td('Continue', TD_THEME_NAME) . '</a>';
$buffy .= '</div>';
} else {
$buffy .= $this->get_content();
}
$buffy .= '<footer class="clearfix">';
$buffy .= $this->get_post_pagination();
$buffy .= $this->get_review();
$buffy .= $this->get_the_tags();
$buffy .= $this->get_source_and_via();
$buffy .= $this->get_social_sharing();
$buffy .= $this->get_next_prev_posts();
$buffy .= $this->get_author_box();
$buffy .= '</footer>';
and replace it with this:
if ($this->show_excerpt === true) { //module 7 uses this
$buffy .= '<p>' . $this->get_excerpt(td_util::get_option('tds_' . 'mod7_content_excerpt')) . '</p>';
$buffy .= '<div class="more-link-wrap wpb_button td_read_more clearfix">';
$buffy .= '<a href="' . $this->href . '">' . __td('Continue', TD_THEME_NAME) . '</a>';
$buffy .= '</div>';
} else {
$buffy .= $this->get_content();
$buffy .= $this->get_author_box();
}
$buffy .= '<footer class="clearfix">';
$buffy .= $this->get_post_pagination();
$buffy .= $this->get_review();
$buffy .= $this->get_the_tags();
$buffy .= $this->get_source_and_via();
$buffy .= $this->get_social_sharing();
$buffy .= $this->get_next_prev_posts();
$buffy .= '</footer>';
You could try adding this to your custom css:
.header-logo-wrap img { margin: -5% 0 -8% 0; }
-
This reply was modified 12 years by
webmaster808.
I just looked at the source of the plugin again and there is a function that returns IDs! Yay!
So in lieu of that, you could try:
// Lets get the IDs of the co-authors
$user_ids = get_coauthors_IDs();
//Iterates through the user ids
foreach($user_ids as $coauthor_id){
//creates an author box for each of the coauthor ids
$buffy .= get_author_box($coauthor_id);
}
If this works, it will only work for co-authors that have an author account in your system that has a unique email address, not the pseudo ones that the plugin can create.
No, unfortunately it’s not that easy. It is looking weird because the coauthors boxes are being returned by the Co Authors plugin(using it’s own markup and styling), while the Author box is being returned by the Newspaper Theme’s functions(using different markup and styling). They are not interchangeable.
However, you can choose to use one or the other system in the template.
In your td_module_1(or whatever one, not td_module_blog) you could try replacing $buffy .= $this->get_author_box(); with:
// Get an array of all the co-authors
$my_coauthors = get_coauthors();
// Count the indexes in the array
if(count($my_coauthors) > 1 ){
// There is more than 1 index in $my_coauthors, output all of them with the coauthor plugin function
$buffy .= get_coauthors();
} else {
// There is only one Author, let's output that one with the Theme function
$buffy .= $this->get_author_box();
}
If you want the output of the Co Author’s plugin to look like the output of the Newspaper Theme Author Box, then you have some css work to do.
The get_author_box() function is what Newspaper uses to display Author info on the front end. This function takes a single user ID and generates everything from that. After a quick glance at the code it looks like what needs to be done is to convert the output of the Co-Authors plugin to an array of IDs so that we can iterate over it to get the get_author_box() function to create the boxes using the Author IDs:
First, you would need something like this(assuming you have the Co-Authors Plus plugin installed) in the functions.php:
if(function_exists('coauthors')){
$coauthor_names = coauthors( null, null, null, null, false );
$user_ids = array();
function coauthor_names_to_ids(){
$names = explode(' ', $coauthor_names);
foreach($names as $name){
// We would probably need to add another function here to make sure that the $name matches any one of our authors slugs and then if $name == 'author-slug' then we could procede to get the ID and add it to the $user_IDs array so that we only have an array of valid IDs.
$user = get_user_by( 'slug', wptexturixe($name));
$user_ids[] .= $user->ID;
}
return $user_ids;
}
coauthor_names_to_ids();
}
And then all you would have to do get them to appear on the front end (in td_module_1 for example) is something like this:
//Iterates through the user ids
foreach($user_ids as $coauthor_id){
//creates an author box for each of the coauthor ids
$buffy .= get_author_box($coauthor_id);
}
I haven’t debugged this code, some work would probably need to be done to make sure the exploded $names array matches slugs properly but it appears to be one way to tackle the problem. Another would be to modify the Co-Authors plugin to be able to return the co-author IDs as well as links. I suppose you could also modify the get_author_box() function to accept the author name as an argument…
-
This reply was modified 12 years by
webmaster808. Reason: Forgot to call the function!
Thanks for the update Radu,
I am very happy to hear that you are aware of the issues and that a fix is near release.