You are here

public function ShortcodeBase::getMidFromPath in Shortcode 8

Same name and namespace in other branches
  1. 2.0.x src/Plugin/ShortcodeBase.php \Drupal\shortcode\Plugin\ShortcodeBase::getMidFromPath()

Extracts the media id from a 'media/x' system path.

Parameters

string $path: The internal path to be translated.

Return value

mixed|int|bool The media id if found.

1 call to ShortcodeBase::getMidFromPath()
ShortcodeBase::getUrlFromPath in src/Plugin/ShortcodeBase.php
Returns a url to be used in a link element given path or url.

File

src/Plugin/ShortcodeBase.php, line 265

Class

ShortcodeBase
Provides a base class for Shortcode plugins.

Namespace

Drupal\shortcode\Plugin

Code

public function getMidFromPath($path) {
  if (preg_match('/media\\/(\\d+)/', $path, $matches)) {
    return $matches[1];
  }
  return FALSE;
}