Add placeholder "No Image" image in editor

master
Skylar Ittner 6 years ago
parent 6de142240e
commit b2d21d51bd

@ -188,6 +188,8 @@ function get_component($name, $context = null, $echo = true, $default = "") {
function is_component_empty($name, $context = null) {
$comp = get_component($name, $context, false);
$comp = strip_tags($comp, "<img><object><video><a>");
$comp = trim($comp);
$comp = str_replace("&nbsp;", "", $comp);
if ($comp == "" && !isset($_GET['edit'])) {
return true;
}
@ -219,11 +221,20 @@ function get_complex_component($name, $context = null, $include = []) {
$filtered = [];
foreach ($include as $i) {
if (array_key_exists($i, $content)) {
$filtered[$i] = $content[$i];
if (!isset($_GET['edit']) && $i == "image" && $content[$i] == URL . "/static/img/no-image.svg") {
$filtered[$i] = "";
} else {
$filtered[$i] = $content[$i];
}
} else {
$filtered[$i] = "";
if (isset($_GET['edit']) && $i == "image") {
$filtered[$i] = URL . "/static/img/no-image.svg";
} else {
$filtered[$i] = "";
}
}
}
return $filtered;
}
@ -239,6 +250,9 @@ function is_complex_empty($name, $context = null) {
}
$comp = get_complex_component($name, $context);
foreach ($comp as $c => $v) {
if ($c == "image" && $v == URL . "/static/img/no-image.svg") {
continue;
}
if (isset($v) && !empty($v)) {
return false;
}

@ -12,6 +12,13 @@ $base = FILE_UPLOAD_PATH;
$filepath = "";
if ($_GET['file'] === URL . "/static/img/no-image.svg") {
header("Content-Type: image/svg+xml");
ob_end_flush();
exit(file_get_contents(__DIR__ . "/../static/img/blankpixel.svg"));
}
if (isset($_GET['file'])) {
$file = $_GET['file'];
$filepath = $base . $file;
@ -47,4 +54,4 @@ header("X-Content-Type-Options: nosniff");
ob_end_flush();
readfile($filepath);
readfile($filepath);

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
version="1.1"
id="svg2"
viewBox="0 0 1 1"
height="1"
width="1">
<defs
id="defs4" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
</svg>

After

Width:  |  Height:  |  Size: 695 B

@ -0,0 +1,95 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="500"
height="200"
viewBox="0 0 500.00001 200"
id="svg2"
version="1.1"
inkscape:version="0.91 r13725"
sodipodi:docname="no-image.svg">
<defs
id="defs4" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="1.4"
inkscape:cx="250"
inkscape:cy="57.691043"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
units="px"
inkscape:window-width="1280"
inkscape:window-height="966"
inkscape:window-x="2464"
inkscape:window-y="60"
inkscape:window-maximized="1" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-852.36216)">
<g
style="font-style:normal;font-weight:normal;font-size:57.19025803px;line-height:125%;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:0.58935361;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
id="text4136">
<path
d="m 161.86892,1019.1548 -8.37748,0 -16.30816,-26.7521 0,26.7521 -8.37748,0 0,-40.65871 8.37748,0 16.33608,26.80791 0,-26.80791 8.34956,0 0,40.65871 z"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:Roboto;-inkscape-font-specification:'Roboto Bold';fill:#000000;fill-opacity:0.58935361"
id="path4210" />
<path
d="m 167.4539,1003.7681 q 0,-4.49587 1.73135,-8.01441 1.73135,-3.51854 4.97064,-5.44536 3.26721,-1.92682 7.56765,-1.92682 6.11556,0 9.9692,3.74194 3.88157,3.74194 4.32837,10.16465 l 0.0559,2.0665 q 0,6.9533 -3.88157,11.1699 -3.88156,4.1888 -10.416,4.1888 -6.53443,0 -10.44392,-4.1888 -3.88157,-4.1887 -3.88157,-11.3933 l 0,-0.3631 z m 8.07031,0.5865 q 0,4.3004 1.61965,6.5903 1.61964,2.2619 4.63553,2.2619 2.93212,0 4.57969,-2.234 1.64757,-2.2619 1.64757,-7.2047 0,-4.21662 -1.64757,-6.53439 -1.64757,-2.31776 -4.63554,-2.31776 -2.96004,0 -4.57968,2.31776 -1.61965,2.28985 -1.61965,7.12089 z"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:Roboto;-inkscape-font-specification:'Roboto Bold';fill:#000000;fill-opacity:0.58935361"
id="path4212" />
<path
d="m 224.83964,1019.1548 -8.37748,0 0,-40.65871 8.37748,0 0,40.65871 z"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:Roboto;-inkscape-font-specification:'Roboto Bold';fill:#000000;fill-opacity:0.58935361"
id="path4214" />
<path
d="m 239.61193,988.94001 0.25132,3.37892 q 3.21137,-3.93742 8.68465,-3.93742 5.83631,0 8.01446,4.60762 3.18344,-4.60762 9.0756,-4.60762 4.91479,0 7.31633,2.87627 2.40155,2.84834 2.40155,8.60088 l 0,19.29614 -8.09823,0 0,-19.26822 q 0,-2.56909 -1.0053,-3.74194 -1.0053,-1.20077 -3.54647,-1.20077 -3.63024,0 -5.02648,3.46269 l 0.0279,20.74824 -8.0703,0 0,-19.24029 q 0,-2.62495 -1.03323,-3.79779 -1.03322,-1.17285 -3.51854,-1.17285 -3.43476,0 -4.97063,2.84834 l 0,21.36259 -8.07031,0 0,-30.21479 7.56766,0 z"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:Roboto;-inkscape-font-specification:'Roboto Bold';fill:#000000;fill-opacity:0.58935361"
id="path4216" />
<path
d="m 299.03619,1019.1548 q -0.5585,-1.0891 -0.80982,-2.7087 -2.93212,3.2672 -7.62351,3.2672 -4.44006,0 -7.37218,-2.5691 -2.9042,-2.5691 -2.9042,-6.4786 0,-4.8031 3.54647,-7.3722 3.57439,-2.5691 10.3043,-2.597 l 3.71402,0 0,-1.73134 q 0,-2.09437 -1.08908,-3.35099 -1.06114,-1.25662 -3.37891,-1.25662 -2.03852,0 -3.21137,0.97737 -1.14492,0.97737 -1.14492,2.68079 l -8.07031,0 q 0,-2.62494 1.61965,-4.85894 1.61964,-2.23399 4.57969,-3.49061 2.96004,-1.28455 6.64613,-1.28455 5.58499,0 8.8522,2.82042 3.29515,2.79249 3.29515,7.87483 l 0,13.09684 q 0.0279,4.3004 1.20077,6.5065 l 0,0.4747 -8.15408,0 z m -6.67406,-5.6129 q 1.7872,0 3.29514,-0.7819 1.50795,-0.8098 2.234,-2.1502 l 0,-5.1941 -3.0159,0 q -6.05971,0 -6.45066,4.1888 l -0.0279,0.4747 q 0,1.5079 1.06115,2.4853 1.06114,0.9774 2.90419,0.9774 z"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:Roboto;-inkscape-font-specification:'Roboto Bold';fill:#000000;fill-opacity:0.58935361"
id="path4218" />
<path
d="m 311.07183,1003.824 q 0,-6.95331 3.29514,-11.1979 3.32307,-4.24459 8.93598,-4.24459 4.97064,0 7.73521,3.40684 l 0.3351,-2.84834 7.31633,0 0,29.20949 q 0,3.9653 -1.81512,6.8974 -1.7872,2.9322 -5.05441,4.468 -3.26722,1.5359 -7.65144,1.5359 -3.32306,0 -6.47858,-1.3404 -3.15552,-1.3125 -4.77516,-3.4068 l 3.57439,-4.9148 q 3.01589,3.3789 7.31633,3.3789 3.21137,0 4.99856,-1.7313 1.7872,-1.7035 1.7872,-4.859 l 0,-1.6196 q -2.79249,3.1555 -7.34426,3.1555 -5.44536,0 -8.82428,-4.2446 -3.35099,-4.2725 -3.35099,-11.3096 l 0,-0.3351 z m 8.07031,0.5864 q 0,4.105 1.64757,6.4507 1.64757,2.3177 4.52384,2.3177 3.68609,0 5.27781,-2.7645 l 0,-12.70586 q -1.61965,-2.76457 -5.22196,-2.76457 -2.9042,0 -4.57969,2.37362 -1.64757,2.37362 -1.64757,7.09291 z"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:Roboto;-inkscape-font-specification:'Roboto Bold';fill:#000000;fill-opacity:0.58935361"
id="path4220" />
<path
d="m 358.76761,1019.7133 q -6.64613,0 -10.83487,-4.0771 -4.16082,-4.077 -4.16082,-10.8628 l 0,-0.7819 q 0,-4.55172 1.75928,-8.12611 1.75927,-3.60231 4.97063,-5.52913 3.23929,-1.95475 7.37218,-1.95475 6.19934,0 9.74581,3.90949 3.57439,3.90949 3.57439,11.0862 l 0,3.2951 -19.24028,0 q 0.39095,2.9601 2.34569,4.7473 1.98267,1.7872 4.99857,1.7872 4.66346,0 7.2884,-3.3789 l 3.96534,4.44 q -1.81512,2.5691 -4.91478,4.0212 -3.09967,1.4242 -6.86954,1.4242 z m -0.92152,-24.79735 q -2.40154,0 -3.90949,1.61964 -1.48002,1.61965 -1.8989,4.63551 l 11.22583,0 0,-0.6422 q -0.0559,-2.68084 -1.4521,-4.13293 -1.39625,-1.48002 -3.96534,-1.48002 z"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:Roboto;-inkscape-font-specification:'Roboto Bold';fill:#000000;fill-opacity:0.58935361"
id="path4222" />
</g>
<path
id="path4209"
d="m 283.25851,934.72779 0,2.77153 c 0,4.59213 -3.72254,8.31464 -8.31464,8.31464 l -66.51701,0 c -4.59209,0 -8.31462,-3.72251 -8.31462,-8.31464 l 0,-44.34468 c 0,-4.59207 3.72253,-8.31458 8.31462,-8.31458 l 2.77155,0 0,36.03004 c 0,7.64114 6.21657,13.85769 13.85771,13.85769 l 58.20238,0 z m 16.62925,-13.85769 0,-44.34468 c 0,-4.59214 -3.72253,-8.31464 -8.31462,-8.31464 l -66.51701,0 c -4.5921,0 -8.31463,3.7225 -8.31463,8.31464 l 0,44.34468 c 0,4.59207 3.72253,8.31464 8.31463,8.31464 l 66.51701,0 c 4.59209,0 8.31462,-3.72257 8.31462,-8.31464 z m -55.43085,-36.03004 c 0,4.59207 -3.72253,8.31458 -8.31461,8.31458 -4.5921,0 -8.31463,-3.72251 -8.31463,-8.31458 0,-4.59213 3.72253,-8.31464 8.31463,-8.31464 4.59209,0 8.31461,3.72251 8.31461,8.31464 z m -16.62924,24.94387 9.61639,-9.6164 c 0.81171,-0.81169 2.12785,-0.81169 2.93974,0 l 6.84467,6.84487 23.47409,-23.47409 c 0.81171,-0.81176 2.12785,-0.81176 2.93973,0 l 15.15929,15.15945 0,19.40081 -60.97392,0 0,-8.31464 z"
inkscape:connector-curvature="0"
style="fill:#000000;fill-opacity:0.58935361" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 8.0 KiB

Loading…
Cancel
Save