Skip to content
Snippets Groups Projects

Maintain aspect ratio.

4 unresolved threads

Closes #3465989

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Vinmayi added 1 commit

    added 1 commit

    Compare with previous version

  • Stephen Mustgrave resolved all threads

    resolved all threads

  • quietone
  • 151 151 $output = $test($input);
    152 152 $this->assertSame($expected_output, $output->getProcessedText());
    153 153 $this->assertEquals($cache_tag, $output->getCacheTags());
    154
    155 // Test cases for aspect ratio maintenance:
    156 // Image with width only; calculate height to maintain aspect ratio.
    157 $input = '<img src="llama.jpg" data-entity-type="file" data-entity-uuid="' . $uuid . '" width="400" />';
    158 $expected_width = 400;
    159 // Calculate height to maintain aspect ratio.
    160 $expected_height = (int) ($height * ($expected_width / $width));
    161 // Note the order of attributes here matches the actual output.
    162 $expected_output = '<img src="/' . $this->siteDirectory . '/files/llama.jpg" data-entity-type="file" data-entity-uuid="' . $uuid . '" width="' . $expected_width . '" height="' . $expected_height . '">';
  • quietone
  • 159 // Calculate height to maintain aspect ratio.
    160 $expected_height = (int) ($height * ($expected_width / $width));
    161 // Note the order of attributes here matches the actual output.
    162 $expected_output = '<img src="/' . $this->siteDirectory . '/files/llama.jpg" data-entity-type="file" data-entity-uuid="' . $uuid . '" width="' . $expected_width . '" height="' . $expected_height . '">';
    163 $output = $test($input);
    164 $this->assertStringContainsString('width="' . $expected_width . '"', $output->getProcessedText());
    165 $this->assertStringContainsString('height="' . $expected_height . '"', $output->getProcessedText());
    166 $this->assertEquals($cache_tag, $output->getCacheTags());
    167
    168 // Image with height only; calculate width to maintain aspect ratio.
    169 $input = '<img src="llama.jpg" data-entity-type="file" data-entity-uuid="' . $uuid . '" height="200" />';
    170 $expected_height = 200;
    171 // Calculate width to maintain aspect ratio.
    172 $expected_width = (int) ($width * ($expected_height / $height));
    173 // Note the order of attributes here matches the actual output.
    174 $expected_output = '<img src="/' . $this->siteDirectory . '/files/llama.jpg" data-entity-type="file" data-entity-uuid="' . $uuid . '" width="' . $expected_width . '" height="' . $expected_height . '">';
  • quietone
  • 151 151 $output = $test($input);
    152 152 $this->assertSame($expected_output, $output->getProcessedText());
    153 153 $this->assertEquals($cache_tag, $output->getCacheTags());
    154
    155 // Test cases for aspect ratio maintenance:
    156 // Image with width only; calculate height to maintain aspect ratio.
    157 $input = '<img src="llama.jpg" data-entity-type="file" data-entity-uuid="' . $uuid . '" width="400" />';
    158 $expected_width = 400;
    159 // Calculate height to maintain aspect ratio.
    160 $expected_height = (int) ($height * ($expected_width / $width));
    161 // Note the order of attributes here matches the actual output.
  • quietone
  • 158 $expected_width = 400;
    159 // Calculate height to maintain aspect ratio.
    160 $expected_height = (int) ($height * ($expected_width / $width));
    161 // Note the order of attributes here matches the actual output.
    162 $expected_output = '<img src="/' . $this->siteDirectory . '/files/llama.jpg" data-entity-type="file" data-entity-uuid="' . $uuid . '" width="' . $expected_width . '" height="' . $expected_height . '">';
    163 $output = $test($input);
    164 $this->assertStringContainsString('width="' . $expected_width . '"', $output->getProcessedText());
    165 $this->assertStringContainsString('height="' . $expected_height . '"', $output->getProcessedText());
    166 $this->assertEquals($cache_tag, $output->getCacheTags());
    167
    168 // Image with height only; calculate width to maintain aspect ratio.
    169 $input = '<img src="llama.jpg" data-entity-type="file" data-entity-uuid="' . $uuid . '" height="200" />';
    170 $expected_height = 200;
    171 // Calculate width to maintain aspect ratio.
    172 $expected_width = (int) ($width * ($expected_height / $height));
    173 // Note the order of attributes here matches the actual output.
    Please register or sign in to reply
    Loading