You are here

private function MediaFileUsageTest::generateFileMarkup in D7 Media 7

Generates markup to be inserted for a file.

This is a PHP version of InsertMedia.insert() from js/wysiwyg-media.js.

Parameters

int $fid: Drupal file id

int $count: Quantity of markup to insert

Return value

string Filter markup.

2 calls to MediaFileUsageTest::generateFileMarkup()
MediaFileUsageTest::createNode in test/media.file.usage.test
Utility function to create a test node.
MediaFileUsageTest::testFileUsageIncrementing in test/media.file.usage.test
Tests the tracking of file usages for files submitted via the WYSIWYG editor.

File

test/media.file.usage.test, line 44
Tests for the file usage in entity fields with the Media filter markup.

Class

MediaFileUsageTest
@file Tests for the file usage in entity fields with the Media filter markup.

Code

private function generateFileMarkup($fid, $count = 1) {
  $file_usage_markup = '';

  // Build the data that is used in a media tag.
  $data = array(
    'fid' => $fid,
    'type' => 'media',
    'view_mode' => 'preview',
    'attributes' => array(
      'height' => 100,
      'width' => 100,
      'classes' => 'media-element file_preview',
    ),
  );

  // Create the file usage markup.
  for ($i = 1; $i <= $count; $i++) {
    $file_usage_markup .= '<p>[[' . drupal_json_encode($data) . ']]</p>';
  }
  return $file_usage_markup;
}