Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > Coding Releases > Coding Snippets
You last visited: Today at 15:28

  • Please register to post and access all features, it's quick, easy and FREE!

 

SVG Placeholder IMG Generator

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Aug 2017
Posts: 154
Received Thanks: 98
SVG Placeholder IMG Generator

Aye folks! This is pretty simple and i guess most of you will understand what this does therefore i'm not saying too much. (:

Code:
<?php

	$width = isset($_GET['w']) ? $_GET['w']: '300';
	$height = isset($_GET['h']) ? $_GET['h']: '200';
	$stroke = isset($_GET['s']) ? $_GET['s']: '222';
	$fill = isset($_GET['f']) ? $_GET['f']: 'fafafa';

	if (preg_match('([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})', $stroke)) { $stroke = '#'.$stroke; }
	if (preg_match('([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})', $fill)) { $fill = '#'.$fill; }

	header('Content-Type: image/svg+xml');

?>

<svg xmlns="http://www.w3.org/2000/svg" width="<?php echo $width; ?>" height="<?php echo $height; ?>">
	<g>

		<rect width="<?php echo $width ?>" height="<?php echo $height; ?>" y="0" x="0" stroke="<?php echo $stroke; ?>" fill="<?php echo $fill; ?>"/>
		<line x1="0" x2="100%" y1="0" y2="100%" stroke="<?php echo $stroke; ?>"/>
		<line x1="100%" x2="0" y1="0" y2="100%" stroke="<?php echo $stroke; ?>"/>

	</g>
</svg>



type. is online now  
Thanks
1 User
Old   #2

 
elite*gold: 2
The Black Market: 226/0/0
Join Date: Apr 2011
Posts: 8,929
Received Thanks: 2,037
Quote:
Originally Posted by type. View Post
Aye folks! This is pretty simple and i guess most of you will understand what this does therefore i'm not saying too much. (:

Code:
<?php

	$width = isset($_GET['w']) ? $_GET['w']: '300';
	$height = isset($_GET['h']) ? $_GET['h']: '200';
	$stroke = isset($_GET['s']) ? $_GET['s']: '222';
	$fill = isset($_GET['f']) ? $_GET['f']: 'fafafa';

	if (preg_match('([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})', $stroke)) { $stroke = '#'.$stroke; }
	if (preg_match('([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})', $fill)) { $fill = '#'.$fill; }

	header('Content-Type: image/svg+xml');

?>

<svg xmlns="http://www.w3.org/2000/svg" width="<?php echo $width; ?>" height="<?php echo $height; ?>">
	<g>

		<rect width="<?php echo $width ?>" height="<?php echo $height; ?>" y="0" x="0" stroke="<?php echo $stroke; ?>" fill="<?php echo $fill; ?>"/>
		<line x1="0" x2="100%" y1="0" y2="100%" stroke="<?php echo $stroke; ?>"/>
		<line x1="100%" x2="0" y1="0" y2="100%" stroke="<?php echo $stroke; ?>"/>

	</g>
</svg>
Oder simpler und ordentlicher:



.aℓsє. is offline  
Thanks
1 User
Old   #3
 
elite*gold: 0
Join Date: Aug 2017
Posts: 154
Received Thanks: 98
Quote:
Originally Posted by .aℓsє. View Post
Oder simpler und ordentlicher:

und langweiliger. :b
type. is online now  
Old   #4
 
elite*gold: 337
Join Date: Feb 2008
Posts: 2,754
Received Thanks: 1,746
If someone is interested in a way to dynamically generate svg placeholder images, then I guess this is something for further reading:
Computerfreek is offline  
Reply

Tags
generator, php, placeholder, svg



« Previous Thread | Next Thread »

Similar Threads
IMG Hochladen IMG SHARING !!!!
Hallo Leute hab ne Tolle Upload Seite gefunden ! Dort knnt ihr eure Bilder Uploaden ! Die Seite ldt schnell da sie sehr schlicht ist ;) !kaum...
3 Replies - Main



All times are GMT +1. The time now is 15:28.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Abuse
Copyright ©2017 elitepvpers All Rights Reserved.