Maintain aspect ratio.
4 unresolved threads
4 unresolved threads
Closes #3465989
Merge request reports
Activity
added 511 commits
-
887f04d4...984772a9 - 509 commits from branch
project:11.x
- 9a212bc1 - Maintain aspect ratio.
- bab613a5 - Code standard fixes.
-
887f04d4...984772a9 - 509 commits from branch
added 1 commit
- Resolved by Stephen Mustgrave
- Resolved by Stephen Mustgrave
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 . '">'; 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 . '">'; 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. 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