1

I recently bought a WordPress theme that does a fancy gallery display of photos and it has been getting the following errors on the homepage.

Warning: Division by zero in /home/content/21/4913121/html/stsudios/wp-content/themes/dt-chocolate/front-gal.php on line 36

Warning: Division by zero in /home/content/21/4913121/html/stsudios/wp-content/themes/dt-chocolate/front-gal.php on line 48

The following is the code through line 50 - the lines with /**/ are the trouble ones. Any help is appreciated!

<?php global $postgallery; $show = $postgallery->get_post_option('show'); $arr = $postgallery->get_post_option('show_'.$show); $arr = explode(",", $arr); $arr = (array)$arr; //$myterms = get_terms('dt_gallery_cat'); $myterms = apply_filters( 'taxonomy-images-get-terms', '', array('taxonomy'=> 'dt_gallery_cat')); $images = array(); global $term, $h; foreach ($myterms as $term) { if ($show == "all") { } elseif ($show == "only") { if ( !in_array( $term->term_id, $arr ) ) continue; } elseif ($show == "except") { if ( in_array( $term->term_id, $arr ) ) continue; } $term->pic = wp_get_attachment_image_src( $term->image_id, 'full' ); $k = $term->pic[1] / $term->pic[2]; /**/$term->pic = $term->pic[0];/**/ $size = taxonomy_get_size( $term->term_id ); if ($size == "s") $w = 220; if ($size == "m") $w = 460; if ($size == "l") $w = 700; /**/$h = ceil($w / $k);/**/ $term->pic = get_template_directory_uri().'/thumb.php?src='.$term->pic.'&amp;w='.$w.'&amp;h='.$h.'&amp;zc=1'; 
4
  • Ask for a refund. Wordpress themes cost money?! Commented Jul 12, 2011 at 16:28
  • Preset $w to a "default" expected size since if $size isn't set, $w isn't being set which is causing part of the problem. Commented Jul 12, 2011 at 16:30
  • 1
    Themeforest themes are scary: "Set CHMOD 777 to folder “your_site/wp-content/themes/dt-chocolate/cache” 2) Folder “your_site/wp-content/uploads” must be created and CHMOD set to 777" Yea, right. Hello, hackers, please hack me. Commented Jul 12, 2011 at 20:12
  • 1
    I'm not a fan of Themeforest myself, but my husband loves their designs. They do have some graphically beautiful themes, but definitely lack on instructions, functionality, and security. Commented Jul 12, 2011 at 20:50

1 Answer 1

2

If you add in some code to check that the values aren't zero it should stop it doing this, but there may be bigger problems.

if ( $term->pic[1] == 0 || $term->pic[2] == 0 ) return 

and / or

$h = ( $w > 0 && $k > 0 ) ? ceil($w / $k) : 0; 

These values probably shouldn't be zero though, so there is likely something else going wrong. Perhaps your images are not in a format readable by the code... or you haven't uploaded any yet

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Ian. I thought the same thing, but after adding in the images, the site works, but still displays the error messages first while the images are loading. Will try this addition.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.