پشتیبانی از SVG

توضیحات

فایل های SVG را با خیال راحت در کتابخانه رسانه خود آپلود کنید و از آنها مانند هر تصویر دیگری استفاده کنید. اکنون با پاکسازی اختیاری!

اما پشتیبانی SVG امکانات بیشتری دارد!!! برای کسب اطلاعات بیشتر به ادامه مطلب مراجعه کنید.

هنگام استفاده از تصاویر SVG در سایت وردپرس خود، استایل دادن به عناصر در SVG با استفاده از CSS ممکن است دشوار باشد. اکنون به راحتی می توانید!

گرافیک بُرداری مقیاس پذیر (SVG) در طراحی وب مدرن رایج شده است، و به شما امکان می دهد تصاویری با اندازه فایل های کوچک را جاسازی کنید که بدون افت کیفیت تا هر اندازه بصری قابل تغییر هستند.

این افزونه نه تنها مانند نامش پشتیبانی از SVG را ارائه می دهد، بلکه به شما اجازه می دهد تا به راحتی کد فایل SVG خود را با استفاده از یک تگ ساده IMG جاسازی کنید.

با افزودن کلاس "style-svg" به عناصر IMG (یا کانتاینر بیرونی)، این افزونه به صورت پویا هر عنصر IMG حاوی SVG در src را که در داخل کلاس هدف یافت می شود با کد SVG کامل شما جایگزین می کند و آن را به صورت درون خطی ارائه می کند.

هدف اصلی این است که امکان استایل و انیمیشن عناصر SVG شما را فراهم کند. معمولاً هنگام استفاده از برچسب‌های embed، object یا img به تنهایی، گزینه‌های استایل شما محدود می‌شوند.

امکانات

  • پشتیبانی از SVG برای کتابخانه رسانه شما
  • آپلودهای SVG را پاکسازی کنید
  • فایل های SVG را کوچک کنید
  • کد SVG خود را وارد کنید
  • عناصر SVG را مستقیماً با استفاده از CSS استایل دهید
  • عناصر SVG را با استفاده از CSS و JS متحرک کنید
  • صفحه تنظیمات فوق العاده آسان با دستورالعمل
  • توانایی آپلود SVG را فقط به مدیران محدود کنید
  • کلاس هدف سفارشی را تنظیم کنید (از 2.4 می توان در عناصر بیرونی استفاده کرد)
  • استفاده بسیار ساده – استفاده پیچیده از فایل های SVG را ساده می کند

کاربرد

ابتدا “پشتیبانی از SVG” (این افزونه) را نصب و فعال کنید.

پس از فعال سازی، می توانید به سادگی تصاویر SVG را مانند هر فایل دیگری در کتابخانه رسانه خود آپلود کنید.

به عنوان یک مدیر، می‌توانید به صفحه مدیریت «تنظیمات > پشتیبانی از SVG» بروید و آپلود فایل‌های SVG را فقط به مدیران محدود کنید.

If you only need to upload SVG files to use as images, you don’t need to enable “Advanced Mode”. Leaving it disabled ensures the frontend script is not enqueued and the unnecessary settings stay hidden.

For advanced use: Enable the “Advanced Mode” under “Settings > SVG Support”.

اکنون می‌توانید پاکسازی و/یا کوچک‌سازی آپلودهای SVG خود را فعال کنید، یک کلاس CSS سفارشی برای هدف‌گیری با برخی تنظیمات دیگر تعریف کنید.

با فعال بودن حالت پیشرفته، شما می توانید تصاویر SVG خود را درست مانند یک تصویر استاندارد با اضافه کردن کلاس "style-svg"(یا کلاس سفارشی که تعریف کردید) به تگ های IMG شما که می خواهید این افزونه با کد SVG واقعی شما جایگزین شود (در نمای متن) جاسازی کنید.

برای مثال:

<img class="style-svg" alt="alt-text" src="image-source.svg" />

یا

<img class="your-custom-class" alt="alt-text" src="image-source.svg" />

اکنون کل عنصر تگ IMG به صورت پویا با کد واقعی SVG شما جایگزین می شود و محتوای داخلی را قابل هدف می کند.
این به شما اجازه می دهد تا با استفاده از CSS و JS عناصر درون SVG خود را هدف قرار دهید.

شما می توانید تمام ویژگی های دیگر را از برچسب IMG حذف کنید زیرا به هر حال ناپدید می شود.

علاوه بر این، اگر نمی‌توانید آن را مستقیماً به خود IMG اضافه کنید، اکنون می‌توانید کلاس هدف را به عناصر بیرونی اضافه کنید. این افزونه فرزندانی را که به دنبال SVG شما برای جایگزینی با کد درون خطی هستند، عبور می دهد.

There’s a setting to automatically add your class to the IMG tag for you when you’re inserting SVG’s in to a post or page, which also removes unnecessary tags.

Since 2.3.11, you can force all SVG files sitewide to be rendered inline with a single checkbox (use with caution). Additionally, you can now choose whether to use the minified or expanded version of the JS file.

Featured Images: If a post/page is saved with your SVG as a featured image, a checkbox will display in the featured image meta box to allow you to render it inline (only if advanced mode is active).

لطفاً توجه داشته باشید: اگر SVG شما نمایش داده نمی شود، احتمالاً با ارتفاع و عرض 0 نمایش داده می شود. در این مورد، باید ارتفاع و عرض خود را در CSS خود تنظیم کنید تا فایل های SVG به درستی نمایش داده شوند.

اگر مشکلی دارید، لطفاً از برگه پشتیبانی استفاده کنید و من تمام تلاشم را می‌کنم که سریع با شما تماس بگیرم

یک سایت آزمایشی را بچرخانید

With a single click, you can spin up a completely free test site to test SVG Support using TasteWP! No sign up, no cards, nothing! How cool is that? Give it a go:
Click Here to spin up a test site in seconds

امنیت

As with allowing uploads of any files, there is potential risks involved. So I have added some features to help!

  • پاکسازی اختیاری برای کمک به حذف هرگونه کد مخرب از فایل های SVG شما در هنگام آپلود.
  • محدود کردن آپلود فقط به مدیر

Only allow users to upload SVG files if you trust them. You have the option to restrict SVG usage to Administrators only from the settings page plus the ability to enable SVG sanitization to attemnpt to clean up any SVG files uploaded.

By default, anyone with Media Library access or upload_files capability will be able to upload SVG files (that is Administrators, Authors and Editors). Please note that SVG files are actually XML which would allow someone to inject malicious code if you’re not careful with who has upload privileges.

بازخورد

I’m open to your suggestions and feedback – Thanks for using SVG Support!

Follow @SVGSupport on Twitter
Follow @benbodhi on Twitter

Note: I hope you like this plugin! Please take a moment to rate it.

ترجمه‌ها

You can contribute your translation here.
New to Translating WordPress?
Read through the Translator Handbook to get started.

عکس‌های صفحه

  • تنظیمات پایه
  • تنظیمات پیشرفته
  • کادر انتخاب تصویر ویژه برای رندر SVG درون خطی
  • SVG مورد استفاده در ابزارک تصویر بومی WP (از نسخه 4.9)
  • SVG درون خطی در نشانه گذاری سمت کاربر
  • برگه راهنما - نمای کلی
  • برگه راهنما - تنظیمات
  • برگه راهنما - استفاده استاندارد
  • برگه راهنما - رندر SVG Inline (استفاده پیشرفته)

سوالات متداول

SVG از زمان به روز رسانی 2.3 به صورت درون خطی ارائه نمی شود

SVG Support 2.3 includes a new settings section called “Advanced Mode”. Users that were inlining SVG files need to make sure this setting is checked. Go to your dashboard > Settings > SVG Support and check “Advanced Mode”. All of your original settings should still be there.

How do I disable the Javascript on the front end if I am not using inline SVG?

If you go to Settings > SVG Support in your admin dashboard, you can choose to enable “Advanced Mode” or not. If you leave it disabled, the advanced functionality and extraneous script is removed.

من سعی می کنم از SVG در سفارشی ساز استفاده کنم اما کار نمی کند.

برای اینکه به SVG اجازه دهید در سفارشی ساز کار کند، باید کدی را در فایل تابع تم فرزند خود تغییر دهید/اضافه کنید. در اینجا یک آموزش عالی در مورد نحوه انجام این کار وجود دارد. بخش مهم این است:

'flex-width'    => true
'flex-height'   => true

چگونه انیمیشن را به SVG خود اضافه کنم؟

شما باید فایل SVG خود را در یک ویرایشگر کد ویرایش کنید تا بتوانید کلاس های CSS را به هر عنصری که باید در SVG هدف قرار دهید اضافه کنید. مطمئن شوید که تگ IMG شما با SVG درون خطی شما تعویض می شود و سپس می توانید از CSS یا JS برای اعمال انیمیشن ها به عناصر داخل فایل SVG خود استفاده کنید.

چرا پشتیبانی SVG در حالت چند سایتی کار نمی کند؟

If you installed multisite prior to WordPress 3.5, then you will need to remove your ms-files. Here is a couple of resources to help you: Dumping ms-files Removing ms-files after 3.5.

چرا SVG من در ویژوال کامپوزر کار نمی کند؟

If you are using SVG Support with Visual Composer or any other page builders, you will need to make sure that you can add your own class to the image. The easiest way to do this is by using a simple text or code block in the builder to put your image code in to. Additionally, there is now a setting to force all SVG files to be rendered inline.

چگونه می توانم با افزونه Media Library Assistant این کار را انجام دهم؟

شما باید نوع mime را برای svg و svgz به “تنظیمات MLA > دستیار کتابخانه رسانه > آپلودها (برگه)” اضافه کنید و سپس کار می کند.

نقد و بررسی‌ها

28 نوامبر 2023
Having the resolution and sharpness of an SVG file is something you can't overlook and getting it can't be any easier than using SVG Support.
12 سپتامبر 2023
is very useful, please add Reset button in Settings :-). tnx
20 آگوست 2023
There are other ways to enable SVG upload with a code snippet. But these are much more insecure as it is not limited to admins or does not support Minify and Sanitize. I have therefore been relying on this plugin for almost 5 years and there have never been any errors. Small bugs were further improved and so I will keep it.
خواندن تمامی 318 نقد و بررسی‌

توسعه دهندگان و همکاران

“پشتیبانی از SVG” نرم افزار متن باز است. افراد زیر در این افزونه مشارکت کرده‌اند.

مشارکت کنندگان

“پشتیبانی از SVG” به 15 زبان ترجمه شده است. با تشکر از مترجمین برای همکاری و کمک‌هایشان.

ترجمه “پشتیبانی از SVG” به زبان شما.

علاقه‌ مند به توسعه هستید؟

Browse the code, check out the SVN repository, or subscribe to the development log by RSS.

تغییرات

2.5.5

  • رفع خطاهای بیشتر و پاکسازی کلی.

2.5.4

  • رفع خطاها.

2.5.3

  • رفع خطای مهلک php.

2.5.2

  • به طور معمول چند پیش فرض برای امنیت بهتر اضافه شده است.

2.5.1

  • نقل قول های گم شده در uninstall.php اضافه شد.

2.5

  • اشتباهات املایی و قالب بندی کلی پاک شد.
  • به نگرانی های امنیتی پرداخته شد.
  • Added more sanitization options – frontend and admin both supported.
  • Added support for SVG minification.
  • Added ability to choose jQuery or vanilla JS.
  • Added DB cleanup on uninstall.
  • Fixed dimensions fallback.

2.4.2

  • Fixed srcset warning for some premium themes.
  • Fixed original IMG IDs not getting preserved on replacement.
  • Removed some rogue text from featured image box.

2.4.1

  • Fixed issue causing WP-CLI to break.

2.4

  • NEW FEATURE: Added optional SVG sanitization.
  • NEW FEATURE: Added optional SVG minification.
  • Added inline SVG checkbox to Gutenberg featured image.
  • Better Gutenberg support in general.
  • Modified class targeting to allow inline rendering of nested SVGs (any level deep) when you can’t set the IMG class directly.
  • Modified JS to use vanilla JS instead of jQuery.
  • Fixed accessibility issues on settings page.
  • Fixed dimensions metadata issue.
  • Fixed division by 0 issue when SVG had no width or height set.
  • Fixed featured image spacing issue in both classic and block editor.
  • Bumped required PHP version.
  • Removed obsolete admin notice.
  • Removed srcset for SVG files.
  • Removed directory name from filepath metadata.

2.3.21

  • Fixed featured image SVG overlapping container.

2.3.20

  • Fixed admin setting not being escaped when output.

2.3.19

  • Fixed PHP Warning from localize_script in functions/enqueue.php.
  • Added a check for SRC attribute in js/svgs-inline.js.

2.3.18

  • Updated author URL in main plugin file.
  • Updated donate links.
  • Cleaned up plugin action meta links and settings page.
  • Rolled back a fix in functions/attachment.php due to it removing meta from other attachments.

2.3.17

  • Added setting to choose whether to load frontend CSS or not.

2.3.16

  • Fix for files that have the XML declaration.
  • Fix for PHP warnings from image widget.
  • Some small CSS changes to the frontend when displaying SVG media attachments.

2.3.15

  • Had to roll back a recent PHP warnings fix due to it breaking some theme compatibility.

2.3.14

  • Fixed: Fatal error in some cases when removing old option from the database.

2.3.13

  • Fixed: PHP warnings and notices from the image widget when using SVG files and wp_debug was on.
  • Modified: Better front end CSS for displaying SVG attachments, both as images and inline.
  • Removed: DB entry for deprecated admin notice.

2.3.12

  • New: Native “Help” tab on the SVG Support settings page.
  • New: Wrapped the inline JS in a function so you can call it at will using bodhisvgsInlineSupport();.
  • Modified: Admin CSS to target SVG src only.
  • Modified: SVG Support settings page – cleaned it up a little.
  • Removed: Version update admin notice.

2.3.11

  • New: Feature to use expanded JS file rather than the minified/compressed version (useful for bundling and minifying using external caching plugins).
  • New: Force Inline SVG option. This feature allows you to force all of your SVG files to be rendered inline regardless of classes applied. Addresses issues where you can’t add your own class to an image for some reason. For example, some page builder image elements. Also addresses changing your target class in the settings and needing to change all of your already embedded media, allowing you to simply force render rather than update all of the classes.
  • Modified the readme file and descriptions a bit.
  • Refined some code in functions/featured-image.php line 69 to address a warning.
  • Updated “Requires at least” tag to 4.8 (though it should still work in older versions, there was issues with core during the 4.7 phase and it’s time for you to update anyway).

2.3.10

  • Fixed missing links in settings page.

2.3.9

  • Modified plugin action meta link for settings page.
  • Changed some language throughout the plugin.
  • Added recommendation for ShortPixel Image Optimization.
  • Added conditional to check post type supports thumbnail before setting meta data.

2.3.8

  • Added some CSS to make sure featured images show on WooCommerce products, Sensei Courses and Lessons.
  • Fix: Auto insert class setting was stripping featured image HTML in some cases.

2.3.7

  • Added WP version check to wrap mime fix function needed for WP v4.7.1 – v4.7.2.
  • Moved mime fix into mime type file.
  • Modified admin notice code to make it neater.
  • Fix: attachment-modal.php issues with some servers and external SVG files (props to @abstractourist & @malthejorgensen for providing fixes, as I could not consistently reproduce the issue).
  • Compatibility: Changed a line to provide wider compatibility, specifically for WordPress Bedrock on a LEMP stack.
  • Compatibility: Added another snippet to the JS to support IE11 (apparently people still use IE).
  • Added more FAQ’s.

2.3.6

  • New: Added polyfill to make svgs-inline.js work with older browsers.
  • New: Section to leave reviews on settings page.
  • Removed: Redundant one time upgrade activate code.
  • Fix: Errors reported on activation and on the settings page – Related Support Thread.

2.3.5

  • Revision and modification of the thumbnail display code.

2.3.4

  • Fix: Fatal error for some because a function wasn’t prefixed.

2.3.3

  • Fix: Missing arguments PHP warnings from new attribute control file.
  • Update settings page text.

2.3.2

  • Modified the attribute control code that auto inserts our class to only apply to SVG files.

2.3.1

  • Fix: Fatal error in some cases due to admin notice.

2.3

  • New Feature – Advanced Mode: allows you to turn off the advanced features and simply upload SVG files like normal images. This addition also enables users to turn off the script added on front end by leaving Advanced Mode unchecked.
  • New Feature – Featured Image Support: If your featured image is SVG, once the post is saved you will see a checkbox to render the SVG inline (advanced mode only).
  • Performance – Stop inlining JS from running if image source is not SVG.
  • Added new stylesheet for settings page.
  • Moved SCSS files to their own folder.
  • Changed donate link so I can track it and properly thank you for your generous donations.
  • Added a rating link to the settings and media pages.
  • Cleaned up code formatting, added more comments.
  • Added a plugin version check.
  • Added notice so people are aware they may need to turn on the advanced mode.

2.2.5

  • FIX: Display SVG thumbnails in attachment modals.

2.2.4

  • FIX: Added function to temporarily fix an issue with uploading in WP 4.7.1

2.2.32

  • Changed text domain to match plugin slug for localization.

2.2.31

  • Attempt to fix ability to translate

2.2.3

  • Modified code in svg-support/js/svg-inline.js and svg-support/js/min/svg-inline-min.js to allow JS control of the SVG elements and detect if they have been loaded (IMG tag swapped out). Thanks to laurosello for this suggestion and code contribution.
  • Fixed SVG thumbnails not displaying correctly in list view of the media library.
  • Cleaned up the code and comments a bit.
  • Added translation for Spanish. Thanks to Apasionados del Marketing for the translation.

2.2.2

  • Changed another anonymous function in svg-support/functions/thumbnail-display.php that was causing errors for some.

2.2.1

  • Changed anonymous function in svg-support/functions/thumbnail-display.php line 15 to prevent fatal error in older PHP versions.

2.2

  • Added support to make SVG thumbnails visible in all media library screens.
  • Added SVGZ to the mime types.
  • Automatically removes the width and height attributes when inserting SVG files.
  • Added ability to choose whether the target class is automatically inserted into img tags or not, stripping the default WordPress classes.
  • Added ability to choose whether script is output in footer – true or false.
  • Blocked direct access to PHP files.
  • Added SCSS support using CodeKit – minified CSS + JS files.
  • Updated spelling for incorrect function name.
  • Changed comment formatting across all files for consistency.
  • Added link to $25 Free credit at GoWebben on the settings page.
  • Tested in WordPress 4.3.
  • Updated Readme file.

2.1.7

  • Tested in WordPress 4.0 and added plugin icons for the new interface.

2.1.6

  • Added missing jQuery dependency in /functions/enqueue.php (pointed out by walbach) – was loading SVG Support JS before jQuery.

2.1.5

  • Added Serbian translation, submitted by Ogi Djuraskovic.

2.1.4

  • Fixed plugin settings link (on plugins page)
  • Added more links – Support & Donate
  • Modified the settings page a little
  • Cleaned up settings page with CSS
  • Satisfied my OCD tendencies a little

2.1.3

  • فایل plugin_action_links برای فهرست های سفارشی در صفحه افزونه اضافه شد.

2.1.2

  • Cleaned up trunk, tags and readme.txt to show correct changelog and update notice.

2.1.1

  • Fixed JS file conditional – worked in local testing but not live.

2.1

  • به روز رسانی فایل های زبان برای بومی سازی.

2.0

  • Added an admin settings page with instructions plus options for restricting to admin use only and setting a custom CSS target class.
  • Whole plugin completely re-written and re-structured.
  • Added option to restrict SVG uploads to administrators only.
  • فیلد برای کلاس هدف CSS سفارشی اضافه شده است.
  • صفحه شیوه نامه به صفحه تنظیمات مدیریت اضافه شد.

1.0

  • انتشار اولیه.