Codeinwp / Codeinwp/wp-menu-icons

SVG inline code

Open
#239 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

new feature
Dominant language
PHP
Stars
82
Forks
25
Avg merge
1d 16h
Merged PRs (30d)
3

Description

What problem does this address?

A user asked if it would be possible to change the way SVG icons are displayed so they can be easily styled with CSS. I'll add his suggestion below.

  After discovering that SVG’s are inserted as src attribute in an <img>, I looked into how I could get it inline and found that editing the includes/front.php and changing one line will do the trick – then you can style how you will with CSS and colours / SVG elements can be targeted for interaction.
  
  The line 492 is the one to edit:
  
  <img src="%s" class="%s" aria-hidden="true" alt="%s"%s%s%s/>',
  
  Changed to:
  
  file_get_contents(esc_url( wp_get_attachment_url( $meta['icon'] ) )),
  
  Will output the raw SVG from the media library.

He also asked if it would be possible to add additional measurement units.

Suggested here.

What is your proposed solution?

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting includes/front.php around line 492 and review the linked WordPress support discussion. Compare the current SVG output with the proposed inline approach and determine how the requested additional measurement units fit the existing icon handling. Done means the intended styling and unit behavior are clearly specified and covered by the relevant project checks.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, wordpress
Domain
frontend, web-dev
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.