You are here

public function PhotosUpload::cleanTitle in Album Photos 8.5

Same name and namespace in other branches
  1. 6.0.x src/PhotosUpload.php \Drupal\photos\PhotosUpload::cleanTitle()

Rename file with random name.

Parameters

string $title: The file name.

Return value

string The new name.

Overrides PhotosUploadInterface::cleanTitle

1 call to PhotosUpload::cleanTitle()
PhotosUpload::saveImage in src/PhotosUpload.php
Attach image file to PhotosImage entity.

File

src/PhotosUpload.php, line 108

Class

PhotosUpload
Functions to help with uploading images to albums.

Namespace

Drupal\photos

Code

public function cleanTitle($title = '') {
  if (\Drupal::config('photos.settings')
    ->get('photos_clean_title')) {

    // Remove extension.
    $title = pathinfo($title, PATHINFO_FILENAME);

    // Replace dash and underscore with spaces.
    $title = preg_replace("/[\\-_]/", " ", $title);

    // Trim leading and trailing spaces.
    $title = trim($title);
  }
  return $title;
}