Удаление лишних изображений
-
Доброе время суток!
Помогите решить следующую проблему.
При работе сборщика новостей, в папке cache грабера wp-o-matic (не WP) скапливаются ненужные изображения. Ручная чистка не помогает, а даже вредит, т.к. удаляются и включенные изображения.
Папка wp-o-matic/cache достигла размера 1Gb!
Кэш уже отключил, и перенес uploads:
define(‘UPLOADS’, ‘wp-content/plugins/wp-o-matic/cache’);
Осталось изменить структуру формирования поддиректорий,надеюсь это поможет найти невключенные изображения из директории и удалить.
Надо убрать 2010/03 и т.п. установить размещение без поддиректорий!
Нашел следующее, но ни как не получается правильно удалить части кода./** * Get an array containing the current upload directory's path and url. * * Checks the 'upload_path' option, which should be from the web root folder, * and if it isn't empty it will be used. If it is empty, then the path will be * 'WP_CONTENT_DIR/uploads'. If the 'UPLOADS' constant is defined, then it will * override the 'upload_path' option and 'WP_CONTENT_DIR/uploads' path. * * The upload URL path is set either by the 'upload_url_path' option or by using * the 'WP_CONTENT_URL' constant and appending '/uploads' to the path. * * If the 'uploads_use_yearmonth_folders' is set to true (checkbox if checked in * the administration settings panel), then the time will be used. The format * will be year first and then month. * * If the path couldn't be created, then an error will be returned with the key * 'error' containing the error message. The error suggests that the parent * directory is not writable by the server. * * On success, the returned array will have many indices: * 'path' - base directory and sub directory or full path to upload directory. * 'url' - base url and sub directory or absolute URL to upload directory. * 'subdir' - sub directory if uploads use year/month folders option is on. * 'basedir' - path without subdir. * 'baseurl' - URL path without subdir. * 'error' - set to false. * * @since 2.0.0 * @uses apply_filters() Calls 'upload_dir' on returned array. * * @param string $time Optional. Time formatted in 'yyyy/mm'. * @return array See above for description. */ function wp_upload_dir( $time = null ) { $siteurl = get_option( 'siteurl' ); $upload_path = get_option( 'upload_path' ); $upload_path = trim($upload_path); if ( empty($upload_path) ) { $dir = WP_CONTENT_DIR . '/uploads'; } else { $dir = $upload_path; if ( 'wp-content/uploads' == $upload_path ) { $dir = WP_CONTENT_DIR . '/uploads'; } elseif ( 0 !== strpos($dir, ABSPATH) ) { // $dir is absolute, $upload_path is (maybe) relative to ABSPATH $dir = path_join( ABSPATH, $dir ); } } if ( !$url = get_option( 'upload_url_path' ) ) { if ( empty($upload_path) || ( 'wp-content/uploads' == $upload_path ) || ( $upload_path == $dir ) ) $url = WP_CONTENT_URL . '/uploads'; else $url = trailingslashit( $siteurl ) . $upload_path; } if ( defined('UPLOADS') ) { $dir = ABSPATH . UPLOADS; $url = trailingslashit( $siteurl ) . UPLOADS; } $bdir = $dir; $burl = $url; $subdir = ''; if ( get_option( 'uploads_use_yearmonth_folders' ) ) { // Generate the yearly and monthly dirs if ( !$time ) $time = current_time( 'mysql' ); $y = substr( $time, 0, 4 ); $m = substr( $time, 5, 2 ); $subdir = "/$y/$m"; } $dir .= $subdir; $url .= $subdir; $uploads = apply_filters( 'upload_dir', array( 'path' => $dir, 'url' => $url, 'subdir' => $subdir, 'basedir' => $bdir, 'baseurl' => $burl, 'error' => false ) ); // Make sure we have an uploads dir if ( ! wp_mkdir_p( $uploads['path'] ) ) { $message = sprintf( __( 'Unable to create directory %s. Is its parent directory writable by the server?' ), $uploads['path'] ); return array( 'error' => $message ); } return $uploads; }
Просмотр 2 ответов — с 1 по 2 (всего 2)
Просмотр 2 ответов — с 1 по 2 (всего 2)
- Тема «Удаление лишних изображений» закрыта для новых ответов.