Delete the preview thumbnails for items in this library. This cannot
            be undone. Recreating media preview files can take hours or even days.
515440
def deleteMediaPreviews(self):
        
        key = '/library/sections/%s/indexes' % self.key
        self._server.query(key, method=self._server._session.delete)
1164709
public function handleDeleteAllImages(): void
	{
		if ($this->request->isAjax()) {
			$result = $this->getStorage()->delete();
			foreach ($result as $row) {
				$this->imageStorage->delete($row);
			}

			$this->redrawControl('gallery');
		} else {
			throw new AbortException;
		}
	}
1105946
def thumbnail_preview(src_path):
  '''  '''
  try:
    assert(exists(src_path))

    width = '1980'

    dest_dir = mkdtemp(prefix='pyglass')
    cmd = [QLMANAGE, '-t', '-s', width, src_path, '-o', dest_dir]
    assert(check_call(cmd) == 0)

    src_filename = basename(src_path)
    dest_list = glob(join(dest_dir, '%s.png' % (src_filename)))
    assert(dest_list)

    dest_path = dest_list[0]
    assert(exists(dest_path))

    return dest_path
  except:
    return None
98858
public function remove_obsolete_thumbnails($storedfiles) {
        // Group found files by filepath ('filepath' in Moodle file storage is dir+name in filesystem repository).
        $files = array();
        foreach ($storedfiles as $file) {
            if (!isset($files[$file->get_filepath()])) {
                $files[$file->get_filepath()] = array();
            }
            $files[$file->get_filepath()][] = $file;
        }

        // Loop through all files and make sure the original exists and has the same contenthash.
        $deletedcount = 0;
        foreach ($files as $filepath => $filesinpath) {
            if ($filecontents = @file_get_contents($this->get_rootpath() . trim($filepath, '/'))) {
                // The 'filename' in Moodle file storage is contenthash of the file in filesystem repository.
                $filename = file_storage::hash_from_string($filecontents);
                foreach ($filesinpath as $file) {
                    if ($file->get_filename() !== $filename && $file->get_filename() !== '.') {
                        // Contenthash does not match, this is an old thumbnail.
                        $deletedcount++;
                        $file->delete();
                    }
                }
            } else {
                // Thumbnail exist but file not.
                foreach ($filesinpath as $file) {
                    if ($file->get_filename() !== '.') {
                        $deletedcount++;
                    }
                    $file->delete();
                }
            }
        }
        if ($deletedcount) {
            mtrace(" instance {$this->id}: deleted $deletedcount thumbnails");
        }
    }
1178115
public function delete()
	{
		$this->getLogger()->info('Deleting media ID ' . $this->mediaId);
		$this->doDelete('/library/' . $this->mediaId);
		
		return true;
	}
862972
private void deleteExtraSnapshots() {
        if (m_snapshots.size() <= m_retain) {
            setState(State.WAITING);
        } else {
            m_lastSysprocInvocation = System.currentTimeMillis();
            setState(State.DELETING);
            final int numberToDelete = m_snapshots.size() - m_retain;
            String pathsToDelete[] = new String[numberToDelete];
            String noncesToDelete[] = new String[numberToDelete];
            for (int ii = 0; ii < numberToDelete; ii++) {
                final Snapshot s = m_snapshots.poll();
                pathsToDelete[ii] = s.path;
                noncesToDelete[ii] = s.nonce;
                SNAP_LOG.info("Snapshot daemon deleting " + s.nonce);
            }
            Object params[] =
                new Object[] {
                    pathsToDelete,
                    noncesToDelete,
                    SnapshotPathType.SNAP_AUTO.toString()
                    };
            long handle = m_nextCallbackHandle++;
            m_procedureCallbacks.put(handle, new ProcedureCallback() {

                @Override
                public void clientCallback(final ClientResponse clientResponse)
                        throws Exception {
                    processClientResponsePrivate(clientResponse);
                }

            });
            m_initiator.initiateSnapshotDaemonWork("@SnapshotDelete", handle, params);
        }
    }
1141188
protected function delete_image() {
    $presets = $this->get_presets();

    foreach ($presets as $key => $preset) {
      $file_name = $this->imagecache_path . $key .'/'. $this->file_name;
      if (File::exists($file_name)) {
        File::delete($file_name);
      }
    }
  }
579070
def cleanup(self):
        
        for key in self._find_keys(identity='image'):
            image_file = self._get(key)

            if image_file and not image_file.exists():
                self.delete(image_file)

        for key in self._find_keys(identity='thumbnails'):
            # We do not need to check for file existence in here since we
            # already did that above for all image references
            image_file = self._get(key)

            if image_file:
                # if there is an image_file then we check all of its thumbnails
                # for existence
                thumbnail_keys = self._get(key, identity='thumbnails') or []
                thumbnail_keys_set = set(thumbnail_keys)

                for thumbnail_key in thumbnail_keys:
                    if not self._get(thumbnail_key):
                        thumbnail_keys_set.remove(thumbnail_key)

                thumbnail_keys = list(thumbnail_keys_set)

                if thumbnail_keys:
                    self._set(key, thumbnail_keys, identity='thumbnails')
                    continue

            # if there is no image_file then this thumbnails key is just
            # hangin' loose, If the thumbnail_keys ended up empty there is no
            # reason for keeping it either
            self._delete(key, identity='thumbnails')
750885
def _cleanPictures(self):
        

        # Project have been deleted
        if not os.path.exists(self.path):
            return
        try:
            pictures = set(os.listdir(self.pictures_directory))
            for drawing in self._drawings.values():
                try:
                    pictures.remove(drawing.ressource_filename)
                except KeyError:
                    pass

            for pict in pictures:
                os.remove(os.path.join(self.pictures_directory, pict))
        except OSError as e:
            log.warning(str(e))
1233196
protected function removeAllImages()
    {
        //Delete old images
        $obImageList = $this->obModel->images;
        if ($obImageList->isEmpty()) {
            return;
        }

        /** @var \System\Models\File $obFile */
        foreach ($obImageList as $obFile) {
            $obFile->deleteThumbs();
            $obFile->delete();
        }
    }
785808
def go_previous_thumbnail(self):
        """"""
        if self.current_thumbnail is not None:
            index = self._thumbnails.index(self.current_thumbnail) - 1
            index = index if index >= 0 else len(self._thumbnails) - 1
            self.set_current_index(index)
            self.scroll_to_item(index)
629722
def previews(self):
        '''
            
        '''
        MAX_PREVIEW_SIZE = 1000000

        def sanitize(bytes):
            return bytes.decode('utf-8', 'ignore')

        def is_code(fname):
            code_endings = ['.c', '.cpp', 'Makefile',
                            '.java', '.py', '.rb', '.js']
            for ending in code_endings:
                if fname.endswith(ending):
                    return True
            return False

        result = []
        try:
            assert(self.attachment.path is not None)
        except ValueError:
            # The file behind the given path does not exist
            return None
        if zipfile.is_zipfile(self.attachment.path):
            zf = zipfile.ZipFile(self.attachment.path, 'r')
            for zipinfo in zf.infolist():
                if zipinfo.file_size < MAX_PREVIEW_SIZE:
                    try:
                        result.append({'name': zipinfo.filename, 'is_code': is_code(
                            zipinfo.filename), 'preview': sanitize(zf.read(zipinfo))})
                    except NotImplementedError as e:
                        result.append(
                                {'name': zipinfo.filename, 'is_code': False, 'preview': '(NotImplementedError: %s)' % (e)})

                    result.append({'name': zipinfo.filename, 'is_code': is_code(
                        zipinfo.filename), 'preview': sanitize(zf.read(zipinfo))})
                else:
                    result.append(
                        {'name': zipinfo.filename, 'is_code': False, 'preview': '(maximum size exceeded)'})
        elif tarfile.is_tarfile(self.attachment.path):
            tf = tarfile.open(self.attachment.path, 'r')
            for tarinfo in tf.getmembers():
                if tarinfo.isfile():
                    if tarinfo.size < MAX_PREVIEW_SIZE:
                        result.append({'name': tarinfo.name, 'is_code': is_code(
                            tarinfo.name), 'preview': sanitize(tf.extractfile(tarinfo).read())})
                    else:
                        result.append(
                            {'name': tarinfo.name, 'is_code': False, 'preview': '(maximum size exceeded)'})
        else:
            # single file
            f = open(self.attachment.path, 'rb')
            fname = f.name[f.name.rfind(os.sep) + 1:]
            result = [{'name': fname, 'is_code': is_code(
                fname), 'preview': sanitize(f.read())}, ]
        return result
410050
public function processThumbnails()
    {
        foreach ($this->findFiles(['is_hidden' => false, 'is_deleted' => false]) as $file) {
            if ($file->isImage) {
                // create tiny thumbnail
                $this->createImage($file->id, $this->getFilterId(TinyCrop::identifier()));
                $this->createImage($file->id, $this->getFilterId(MediumThumbnail::identifier()));
            }
        }

        // force auto fix
        $this->autoFixMissingImageSources = true;

        foreach ($this->findImages() as $image) {
            if (!empty($image->file) && !$image->file->isHidden && !$image->file->isDeleted) {
                $image->source; // which forces to recreate missing sources.
            }
        }

        return true;
    }
545856
def _delete_images(self, instance):
        """"""
        UserMediaImage.objects.filter(
            content_type=ContentType.objects.get_for_model(instance),
            object_id=instance.pk,
            user=instance.user,
        ).delete()
459893
public void cleanup(boolean reuse, boolean wasInsert)
    {
        if(currentImage != null)
        {
            performImageCleanup(currentImage, reuse);
        }
        if(beforeImage != null)
        {
            // we always free all resources of the old image
            performImageCleanup(beforeImage, false);
        }
        if(reuse)
        {
            refreshObjectImage(wasInsert);
        }
        else
        {
            myObj = null;
        }
    }
1006711
public function actionClearAllThumbnails()
    {
        /**
         * @var $files StorageFile[]
         */
        ini_set('memory_limit', '2048M');

        if ($files = StorageFile::find()->count()) {
            foreach (StorageFile::find()->orderBy(['id' => SORT_ASC])->each(100) as $file) {
                $this->stdout("{$file->id}");
                if ($file->deleteTmpDir()) {
                    $this->stdout(" - true\n", Console::FG_GREEN);
                } else {
                    $this->stdout(" - false\n", Console::FG_RED);
                }
            }
        }
    }
218337
def remove_thumbnail(self, thumbnail):
        """"""
        if thumbnail in self._thumbnails:
            index = self._thumbnails.index(thumbnail)
            self._thumbnails.remove(thumbnail)
        self.layout().removeWidget(thumbnail)
        thumbnail.deleteLater()
        thumbnail.sig_canvas_clicked.disconnect()
        thumbnail.sig_remove_figure.disconnect()
        thumbnail.sig_save_figure.disconnect()

        # Select a new thumbnail if any :
        if thumbnail == self.current_thumbnail:
            if len(self._thumbnails) > 0:
                self.set_current_index(min(index, len(self._thumbnails)-1))
            else:
                self.current_thumbnail = None
                self.figure_viewer.figcanvas.clear_canvas()