Skip to content

Commit

Permalink
API Remove deprecated API
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Jan 6, 2025
1 parent 8ae974d commit 1691bf8
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 58 deletions.
23 changes: 0 additions & 23 deletions src/Shortcodes/ImageShortcodeProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use SilverStripe\Assets\Image;
use SilverStripe\Core\Flushable;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Dev\Deprecation;
use SilverStripe\View\Parsers\ShortcodeHandler;
use SilverStripe\View\Parsers\ShortcodeParser;

Expand Down Expand Up @@ -150,28 +149,6 @@ public static function handle_shortcode($args, $content, $parser, $shortcode, $e
return $markup;
}

/**
* Construct and return HTML image tag.
*
* @deprecated 2.3.0
*/
public static function createImageTag(array $attributes) : string
{
Deprecation::notice('2.3.0', 'Will be removed without equivalent functionality to replace it.');
$preparedAttributes = '';
foreach ($attributes as $attributeKey => $attributeValue) {
if (strlen($attributeValue ?? '') > 0 || $attributeKey === 'alt') {
$preparedAttributes .= sprintf(
' %s="%s"',
$attributeKey,
htmlspecialchars($attributeValue ?? '', ENT_QUOTES, 'UTF-8', false)
);
}
}

return "<img{$preparedAttributes} />";
}

/**
* Regenerates "[image id=n]" shortcode with new src attribute prior to being edited within the CMS.
*
Expand Down
1 change: 0 additions & 1 deletion src/Storage/DBFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use SilverStripe\Control\Director;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Forms\FormField;
use SilverStripe\Dev\Deprecation;
use SilverStripe\ORM\FieldType\DBComposite;
use SilverStripe\Core\Validation\ValidationException;
use SilverStripe\Core\Validation\ValidationResult;
Expand Down
34 changes: 0 additions & 34 deletions tests/php/Shortcodes/ImageShortcodeProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -472,40 +472,6 @@ public function testWhiteIsConfigurable()
);
}

public static function gettersAndSettersProvider(): array
{
return [
'image without special characters' => [
'<img src="http://example.com/image.jpg" alt="My alt text" title="My Title" width="300" height="200" class="leftAlone ss-htmleditorfield-file image" />',
[
'src' => 'http://example.com/image.jpg',
'alt' => 'My alt text',
'title' => 'My Title',
'width' => '300',
'height' => '200',
'class' => 'leftAlone ss-htmleditorfield-file image',
],
],
'image with special characters' => [
'<img src="http://example.com/image.jpg" alt="My alt text &amp; special character" title="My Title &amp; special character" width="300" height="200" class="leftAlone ss-htmleditorfield-file image" />',
[
'src' => 'http://example.com/image.jpg',
'alt' => 'My alt text &amp; special character',
'title' => 'My Title & special character',
'width' => '300',
'height' => '200',
'class' => 'leftAlone ss-htmleditorfield-file image',
]
]
];
}

#[DataProvider('gettersAndSettersProvider')]
public function testCreateImageTag(string $expected, array $attributes)
{
$this->assertEquals($expected, ImageShortcodeProvider::createImageTag($attributes));
}

/**
* This method will assert that the $tag will contain an image with specific attributes and values
*
Expand Down

0 comments on commit 1691bf8

Please sign in to comment.