function &create(&$root, &$pipeline) { $name = $root->get_attribute('name'); $value = $root->get_attribute('value'); $url_autofix = new AutofixUrl(); $src = $url_autofix->apply(trim($root->get_attribute("src"))); $src_img = ImageFactory::get($pipeline->guess_url($src), $pipeline); if (is_null($src_img)) { error_log(sprintf("Cannot open image at '%s'", $src)); if ($root->has_attribute('width')) { $width = px2pt($root->get_attribute('width')); } else { $width = px2pt(BROKEN_IMAGE_DEFAULT_SIZE_PX); } if ($root->has_attribute('height')) { $height = px2pt($root->get_attribute('height')); } else { $height = px2pt(BROKEN_IMAGE_DEFAULT_SIZE_PX); } $alt = $root->get_attribute('alt'); $css_state =& $pipeline->get_current_css_state(); $box =& new ButtonBrokenImagebox($width, $height, $alt, $name, $value, $css_state->get_property(CSS_HTML2PS_FORM_ACTION)); $box->readCSS($css_state); return $box; } $css_state =& $pipeline->get_current_css_state(); $box =& new ButtonImageBox($src_img, $name, $value, $css_state->get_property(CSS_HTML2PS_FORM_ACTION)); $box->readCSS($css_state); $box->_setupSize(); return $box; }
function parse($value, &$pipeline) { global $g_config; if (!$g_config['renderimages']) { return CSSBackgroundImage::default_value(); } if ($value === 'inherit') { return CSS_PROPERTY_INHERIT; } // 'url' value if (preg_match("/url\\((.*[^\\\\]?)\\)/is", $value, $matches)) { $url = $matches[1]; $full_url = $pipeline->guess_url(css_remove_value_quotes($url)); return new BackgroundImage($full_url, ImageFactory::get($full_url, $pipeline)); } // 'none' and unrecognzed values return CSSBackgroundImage::default_value(); }
function parse($value, &$pipeline) { if ($value === 'inherit') { return CSS_PROPERTY_INHERIT; } global $g_config; if (!$g_config['renderimages']) { return CSSListStyleImage::default_value(); } if (preg_match('/url\\(([^)]+)\\)/', $value, $matches)) { $url = $matches[1]; $full_url = $pipeline->guess_url(css_remove_value_quotes($url)); return new ListStyleImage($full_url, ImageFactory::get($full_url, $pipeline)); } /** * 'none' value and all unrecognized values */ return CSSListStyleImage::default_value(); }
function &create(&$root, &$pipeline) { // Open image referenced by HTML tag // Some crazy HTML writers add leading and trailing spaces to SRC attribute value - we need to remove them // $url_autofix = new AutofixUrl(); $src = $url_autofix->apply(trim($root->get_attribute("src"))); $image_url = $pipeline->guess_url($src); $src_img = ImageFactory::get($image_url, $pipeline); if (is_null($src_img)) { // image could not be opened, use ALT attribute if ($root->has_attribute('width')) { $width = px2pt($root->get_attribute('width')); } else { $width = px2pt(BROKEN_IMAGE_DEFAULT_SIZE_PX); } if ($root->has_attribute('height')) { $height = px2pt($root->get_attribute('height')); } else { $height = px2pt(BROKEN_IMAGE_DEFAULT_SIZE_PX); } $alt = $root->get_attribute('alt'); $box =& new BrokenImgBox($width, $height, $alt); $box->readCSS($pipeline->getCurrentCSSState()); $box->put_width($width); $box->put_height($height); $box->default_baseline = $box->get_full_height(); $box->src_height = $box->get_height(); $box->src_width = $box->get_width(); return $box; } else { $box =& new ImgBox($src_img); $box->readCSS($pipeline->getCurrentCSSState()); $box->_setupSize(); return $box; } }