function deleteImageFile($post_id) { if (file_exists(image_name($post_id))) { unlink(image_name($post_id)); return true; } return false; }
function image_panels($admin_images, $node = array()) { $phtml = ""; // add a text filter like other site pages $phtml .= "<label for='filter' id='image_filter_name'>filter images by typing (searches name, gallery status and main status):</label>"; $phtml .= "<input id='image_list_filter' class='filter form_field' type='text' autofocus='autofucus'/>"; $phtml .= "<script type='text/javascript'>"; $phtml .= " \$('.filter').on('keyup',filter);"; $phtml .= " function filter()"; $phtml .= " {"; $phtml .= " var value=\$('.filter').val();"; $phtml .= " if (value!='')"; $phtml .= " { "; $phtml .= " \$('.image_panel_list .aim_panel').css('display','none');\t"; $phtml .= " value=value.replace(/\\W/g,'').toLowerCase();"; $phtml .= " \$('.image_panel_list [id*='+value+']').css('display','block');"; $phtml .= " }"; $phtml .= " else"; $phtml .= " {"; $phtml .= " \$('.image_panel_list .aim_panel').css('display','block');"; $phtml .= " }"; $phtml .= " }"; $phtml .= "</script>"; foreach ($admin_images as $ai) { // a jsid for filtering if (1 == $ai['in_gallery'] ? $gal = 'ingallery' : ($gal = '')) { } if (1 == $ai['main'] ? $main = 'main' : ($main = '')) { } $jsid = strtolower(preg_replace("/[^A-Za-z0-9]/", '', $ai['image_name'] . $ai['image_ext'] . $gal . $main)); // set up the variables for this loop if ($ai["main"] == 1 ? $main = ' checked ' : ($main = '')) { } if ($ai["in_gallery"] == 1 ? $gallery = " checked='checked' " : ($gallery = '')) { } $id = $ai["node_id"]; $name = $ai["image_name"]; $display_name = image_name($ai); $src = "/user_img/" . $ai['user_id'] . "/" . $ai['image_filename'] . "t300" . $ai['image_ext']; // set the image dimensions for the thumbnail panels $thumb_ratio = getimagesize($_SERVER['DOCUMENT_ROOT'] . $src); if (is_numeric($this->config->item('aim_list_size')) ? $thumb_size = $this->config->item('aim_list_size') : ($thumb_size = 180)) { } if ($thumb_ratio[0] >= $thumb_ratio[1] ? $image_wh = " width='" . $thumb_size . "' height='' " : ($image_wh = " width='' height='" . $thumb_size . "' ")) { } // image tag $thumbnail_tag = "<img src='" . $src . "' " . $image_wh . "/>"; // classes for marking main and gallery if ($ai["main"] == 1 ? $extra_classes = ' main_mark ' : ($extra_classes = ' ')) { } if ($ai["in_gallery"] == 1 ? $extra_classes .= " gallery_mark " : ($extra_classes .= ' ')) { } // open panel $phtml .= "<span id='" . $jsid . "' class='aim_panel " . $extra_classes . "'>"; // remove check, not for main image, or all images list if (1 == $ai["main"] or 0 == count($node)) { $phtml .= "<div class='aim_remove'> </div>"; } else { $phtml .= "<div class='aim_remove'><input id='remove" . $id . "' type='checkbox' name='" . $id . "remove' onclick='mark_remove()'/> <label for='remove" . $id . "'>remove</label></div>"; } // thumbnail image and edit link $phtml .= "<span class='aim_thumb'><a href='/images/edit/" . $ai['node_id'] . "'>" . $thumbnail_tag . "</a></span>"; // name with counter and javascript function for processing count $phtml .= "<input id='" . $id . "name' class='aim_name form_field' type='text' name='" . $id . "name' value='" . $name . "' maxlength='140' onkeyup='char_count(\"" . $id . "\",\"name\",140)'/>"; $phtml .= "<div id='" . $id . "name_count' class='char_counter chars_ok'></div>"; $phtml .= "<script type='text/javascript'>"; $phtml .= "if (window.focus)"; $phtml .= "{"; $phtml .= "\$('#" . $id . "name_count').html(140-\$('#" . $id . "name').val().length);"; $phtml .= "}"; $phtml .= "</script>"; // main and gallery buttons $phtml .= "<div class='aim_buttons'>"; if (count($node)) { $phtml .= "<div class='aim_main'><input id='main" . $id . "' type='radio' name='main' value='" . $id . "' " . $main . "/> <label for='main" . $id . "'>main</label></div>"; } $phtml .= "<div class='aim_ingallery'><input id='gallery" . $id . "' type='checkbox' name='" . $id . "gallery' " . $gallery . "/> <label for='gallery" . $id . "'>in gallery</label></div>"; $phtml .= "</div>"; // close panel $phtml .= "</span>"; } return $phtml; }
function image_url($post_id) { return url() . "/" . image_name($post_id); }