Safe SVG

Beschreibung

Safe SVG ist der beste Weg, um das Hochladen von SVGs in WordPress zu ermöglichen!

Es ermöglicht, SVG-Uploads zuzulassen und gleichzeitig sicherzustellen, dass sie bereinigt werden, um zu verhindern, dass SVG-/XML-Schwachstellen die Website beeinträchtigen. Außerdem werden die hochgeladenen SVGs in der Medienbibliothek in allen Ansichten in der Vorschau angezeigt.

Aktuelle Funktionen

  • Bereinigte SVGs – Öffne keine Sicherheitslücken in deiner WordPress-Website, indem du den Upload von nicht bereinigten Dateien erlauben.
  • SVGO Optimisation – Runs your SVGs through the SVGO tool on upload to save you space. This feature is disabled by default but can be enabled by adding the following code: add_filter( 'safe_svg_optimizer_enabled', '__return_true' );
  • SVGs in der Mediathek anzeigen – Die Zeiten sind vorbei, in denen man raten musste, welches SVG das richtige ist. Wir aktivieren SVG-Vorschauen in der WordPress-Mediathek.
  • Bestimme, wer hochladen darf – Schränke SVG-Uploads auf bestimmte Benutzer auf deiner WordPress-Website ein oder erlaube jedem, diese hochzuladen.

Ursprünglich ein Proof of Concept für #24251.

Die SVG-Bereinigung wird durch die folgende Bibliothek durchgeführt: https://github.com/darylldoyle/svg-sanitizer.

SVG Optimization is done through the following library: https://github.com/svg/svgo.

Blöcke

Dieses Plugin unterstützt 1 Block.

  • Safe SVG Display the SVG icon

Installation

Install through the WordPress directory or download, unzip and upload the files to your /wp-content/plugins/ directory

FAQ

Können wir die erlaubten Attribute und Tags ändern?

Ja, dies kann mit Hilfe der Filter svg_allowed_attributes und svg_allowed_tags geschehen.
Es wird dafür ein Argument benötigt, das zurückgegeben werden muss. Siehe nachfolgende Beispiele:

add_filter( 'svg_allowed_attributes', function ( $attributes ) {

    // Do what you want here...

    // This should return an array so add your attributes to
    // to the $attributes array before returning it. E.G.

    $attributes[] = 'target'; // This would allow the target="" attribute.

    return $attributes;
} );


add_filter( 'svg_allowed_tags', function ( $tags ) {

    // Do what you want here...

    // This should return an array so add your tags to
    // to the $tags array before returning it. E.G.

    $tags[] = 'use'; // This would allow the <use> element.

    return $tags;
} );

Rezensionen

21. Juni 2025 1 Antwort
Would have given a 5 star, but it seems support is missing for the taxonomy / terms section (like in categories) upload for SVG images. Keep getting an error that the upload isn’t supported. Hopefully this will be fixed in a future update. Will update once this is added. Cheers!
30. April 2025 1 Antwort
Great plugin! very usefull, but please can you add the possibility to add an inline SVG on the block pasting svg code? Thanks!
Alle 75 Rezensionen lesen

Mitwirkende & Entwickler

„Safe SVG“ ist Open-Source-Software. Folgende Menschen haben an diesem Plugin mitgewirkt:

Mitwirkende

„Safe SVG“ wurde in 29 Sprachen übersetzt. Danke an die Übersetzerinnen und Übersetzer für ihre Mitwirkung.

Übersetze „Safe SVG“ in deine Sprache.

Interessiert an der Entwicklung?

Durchstöbere den Code, sieh dir das SVN Repository an oder abonniere das Entwicklungsprotokoll per RSS.

Änderungsprotokoll

2.3.1 – 2024-12-05

2.3.0 – 2024-11-25

2.2.6 – 2024-08-28

2.2.5 – 2024-06-27

2.2.4 – 2024-03-28

2.2.3 – 2024-03-20

2.2.2 – 2023-11-21

2.2.1 – 2023-10-23

2.2.0 – 2023-08-21

View historical changelog details here.