OsCommerce Images Stretched - Contributions not working - php

On this site (link to product page: http://www.boatingsupplynow.com/product_info.php?cPath=979_1044&products_id=29943) the images appear stretched.
I have applied 2 different image stretch contribution fixes, neither seem to work. I have attached a screenshot of my images settings on the admin side. Please help!!
<?php
/*
$Id$
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2010 osCommerce
Released under the GNU General Public License
*/
////
// The HTML href link wrapper function
function tep_href_link($page = '', $parameters = '', $connection = 'NONSSL', $add_session_id = true, $search_engine_safe = true) {
global $request_type, $session_started, $SID;
$page = tep_output_string($page);
if (!tep_not_null($page)) {
die('</td></tr></table></td></tr></table><br /><br /><font color="#ff0000"><strong>Error!</strong></font><br /><br /><strong>Unable to determine the page link!<br /><br />');
}
if ($connection == 'NONSSL') {
$link = HTTP_SERVER . DIR_WS_HTTP_CATALOG;
} elseif ($connection == 'SSL') {
if (ENABLE_SSL == true) {
$link = HTTPS_SERVER . DIR_WS_HTTPS_CATALOG;
} else {
$link = HTTP_SERVER . DIR_WS_HTTP_CATALOG;
}
} else {
die('</td></tr></table></td></tr></table><br /><br /><font color="#ff0000"><strong>Error!</strong></font><br /><br /><strong>Unable to determine connection method on a link!<br /><br />Known methods: NONSSL SSL</strong><br /><br />');
}
if (tep_not_null($parameters)) {
$link .= $page . '?' . tep_output_string($parameters);
$separator = '&';
} else {
$link .= $page;
$separator = '?';
}
while ( (substr($link, -1) == '&') || (substr($link, -1) == '?') ) $link = substr($link, 0, -1);
// Add the session ID when moving from different HTTP and HTTPS servers, or when SID is defined
if ( ($add_session_id == true) && ($session_started == true) && (SESSION_FORCE_COOKIE_USE == 'False') ) {
if (tep_not_null($SID)) {
$_sid = $SID;
} elseif ( ( ($request_type == 'NONSSL') && ($connection == 'SSL') && (ENABLE_SSL == true) ) || ( ($request_type == 'SSL') && ($connection == 'NONSSL') ) ) {
if (HTTP_COOKIE_DOMAIN != HTTPS_COOKIE_DOMAIN) {
$_sid = tep_session_name() . '=' . tep_session_id();
}
}
}
if (isset($_sid)) {
$link .= $separator . tep_output_string($_sid);
}
while (strstr($link, '&&')) $link = str_replace('&&', '&', $link);
if ( (SEARCH_ENGINE_FRIENDLY_URLS == 'true') && ($search_engine_safe == true) ) {
$link = str_replace('?', '/', $link);
$link = str_replace('&', '/', $link);
$link = str_replace('=', '/', $link);
} else {
$link = str_replace('&', '&', $link);
}
return $link;
}
////
// The HTML image wrapper function
// Replaces original OScommerce img tag's with call-to image.php(GD-library imagecopyresampled)
// JPG, BMP images will optimized prior to downloading
// GIF, PNG will not be optimized
// Frank Swayze 09/28/2008
function tep_image($src, $alt = '', $width = '', $height = '', $parameters = '', $stretch='false') {
if ( (empty($src) || ($src == DIR_WS_IMAGES)) && (IMAGE_REQUIRED == 'false') ) {
return false;
}
$img_type = exif_imagetype($src);
// alt is added to the img tag even if it is null to prevent browsers from outputting
// the image filename as default
// calculate any missing dimensions from function call. Necessary if image is to be resized.
if (empty($width) || empty($height)) {
if ($image_size = #getimagesize($src)) {
if (empty($width) && !empty($height)) {
$ratio = $height / $image_size[1];
$width = intval($image_size[0] * $ratio);
} elseif (!empty($width) && empty($height)) {
$ratio = $width / $image_size[0];
$height = intval($image_size[1] * $ratio);
} elseif (empty($width) && empty($height)) {
$width = $image_size[0];
$height = $image_size[1];
}
} elseif (IMAGE_REQUIRED == 'false') {
return false;
}
}
if (($img_type != IMAGETYPE_GIF && $img_type != IMAGETYPE_PNG) && (!(file_exists(DIR_FS_CATALOG . $src)) || filesize(DIR_FS_CATALOG . $src) > 30)) { // if checks for existance of file and skips resizing for files less than 3000bytes( 3 Kb)
$image = '<img src="image.php?src=' . htmlspecialchars($src) . '&width=' . htmlspecialchars($width) . '&height=' . htmlspecialchars($height) . '"';
} else {
$image = '<img src="' . htmlspecialchars($src) . '" width="' . htmlspecialchars($width) . '" height="' . htmlspecialchars($height) . '"';
}
$image .= ' border="0" alt="' . htmlspecialchars($alt) . '"';
if (!empty($alt)) {
$image .= ' title=" ' . htmlspecialchars($alt) . ' "';
}
if (!empty($parameters)) $image .= ' ' . $parameters;
$image .= '>';
return $image;
}
////
// The HTML form submit button wrapper function
// Outputs a button in the selected language
function tep_image_submit($image, $alt = '', $parameters = '') {
global $language;
$image_submit = '<input type="image" src="' . tep_output_string(DIR_WS_LANGUAGES . $language . '/images/buttons/' . $image) . '" alt="' . tep_output_string($alt) . '"';
if (tep_not_null($alt)) $image_submit .= ' title=" ' . tep_output_string($alt) . ' "';
if ( (CONFIG_CALCULATE_IMAGE_SIZE == 'true') )
{
if ($image_size = #getimagesize($src))
{
if (empty($width) && tep_not_null($height))
{
if (($image_size[1] < $height) && ($stretch=='false'))
{
// EC - if width hasn't been passed in, the image height is smaller than the setting, and stretch is false, use original dimensions
$width=$image_size[0];
$height=$image_size[1];
}
else
{
// EC - if width hasn't been passed, and the image height is larger than the setting, height ends up as the setting and width is modified to suit
$ratio = $height / $image_size[1];
$width = $image_size[0] * $ratio;
}
}
elseif (tep_not_null($width) && empty($height))
{
// EC - if height hasn't been passed in, the image width is smaller than the setting, and stretch is false, use original dimensions
if (($image_size[0] < $width) && ($stretch=='false'))
{
$width=$image_size[0];
$height=$image_size[1];
}
else
{
// EC - if height hasn't been passed, and the image width is larger than the setting, width ends up as the setting and height is modified to suit
$ratio = $width / $image_size[0];
$height = $image_size[1] * $ratio;
}
}
elseif (empty($width) && empty($height))
{
// EC - if neither height nor width are passed in, just use the original dimensions
$width = $image_size[0];
$height = $image_size[1];
}
//EC - added the following elseif for calculating based on stretch/no-stretch
elseif (tep_not_null($width) && tep_not_null($height))
{
if ((($image_size[0] > $width) || ($image_size[1] > $height)) && ($stretch=='false'))
{
// EC - if width and height are both passed in, either original height or width are larger than the setting, and stretch is false, resize both dimensions to suit
$new_ratio=$height / $width;
$image_ratio=$image_size[1] / $image_size[0];
if ($new_ratio >= $image_ratio)
{
$height=$image_size[1]*($width/$image_size[0]);
}
else
{
$width=$image_size[0]*($height/$image_size[1]);
}
}
elseif ($stretch=='false')
{
// EC - if we got here, both width and height have been passed in, both original height and width are smaller than setting, and stretch is set to false. So just use original dimensions.
$width=$image_size[0];
$height=$image_size[1];
}
}
}
elseif (IMAGE_REQUIRED == 'false')
{
return false;
}
}
if (tep_not_null($width) && tep_not_null($height)) {
$image .= ' width="' . tep_output_string($width) . '" height="' . tep_output_string($height) . '"';
}
if (tep_not_null($parameters)) $image_submit .= ' ' . $parameters;
$image_submit .= ' />';
return $image_submit;
}
////
// Output a function button in the selected language
function tep_image_button($image, $alt = '', $parameters = '') {
global $language;
return tep_image(DIR_WS_LANGUAGES . $language . '/images/buttons/' . $image, $alt, '', '', $parameters);
}
////
// Output a separator either through whitespace, or with an image
function tep_draw_separator($image = 'pixel_black.gif', $width = '100%', $height = '1') {
return tep_image(DIR_WS_IMAGES . $image, '', $width, $height);
}
////
// Output a form
function tep_draw_form($name, $action, $method = 'post', $parameters = '', $tokenize = false) {
global $sessiontoken;
$form = '<form name="' . tep_output_string($name) . '" action="' . tep_output_string($action) . '" method="' . tep_output_string($method) . '"';
if (tep_not_null($parameters)) $form .= ' ' . $parameters;
$form .= '>';
if ( ($tokenize == true) && isset($sessiontoken) ) {
$form .= '<input type="hidden" name="formid" value="' . tep_output_string($sessiontoken) . '" />';
}
return $form;
}
////
// Output a form input field
function tep_draw_input_field($name, $value = '', $parameters = '', $type = 'text', $reinsert_value = true) {
global $HTTP_GET_VARS, $HTTP_POST_VARS;
$field = '<input type="' . tep_output_string($type) . '" name="' . tep_output_string($name) . '"';
if ( ($reinsert_value == true) && ( (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name])) || (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name])) ) ) {
if (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name])) {
$value = stripslashes($HTTP_GET_VARS[$name]);
} elseif (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name])) {
$value = stripslashes($HTTP_POST_VARS[$name]);
}
}
if (tep_not_null($value)) {
$field .= ' value="' . tep_output_string($value) . '"';
}
if (tep_not_null($parameters)) $field .= ' ' . $parameters;
$field .= ' />';
return $field;
}
////
// Output a form password field
function tep_draw_password_field($name, $value = '', $parameters = 'maxlength="40"') {
return tep_draw_input_field($name, $value, $parameters, 'password', false);
}
////
// Output a selection field - alias function for tep_draw_checkbox_field() and tep_draw_radio_field()
function tep_draw_selection_field($name, $type, $value = '', $checked = false, $parameters = '') {
global $HTTP_GET_VARS, $HTTP_POST_VARS;
$selection = '<input type="' . tep_output_string($type) . '" name="' . tep_output_string($name) . '"';
if (tep_not_null($value)) $selection .= ' value="' . tep_output_string($value) . '"';
if ( ($checked == true) || (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name]) && (($HTTP_GET_VARS[$name] == 'on') || (stripslashes($HTTP_GET_VARS[$name]) == $value))) || (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name]) && (($HTTP_POST_VARS[$name] == 'on') || (stripslashes($HTTP_POST_VARS[$name]) == $value))) ) {
$selection .= ' checked="checked"';
}
if (tep_not_null($parameters)) $selection .= ' ' . $parameters;
$selection .= ' />';
return $selection;
}
////
// Output a form checkbox field
function tep_draw_checkbox_field($name, $value = '', $checked = false, $parameters = ' style="background:none;border:0px;"') {
return tep_draw_selection_field($name, 'checkbox', $value, $checked, $parameters);
}
////
// Output a form radio field
function tep_draw_radio_field($name, $value = '', $checked = false, $parameters = ' style="background:none;border:0px;"') {
return tep_draw_selection_field($name, 'radio', $value, $checked, $parameters);
}
////
// Output a form textarea field
// The $wrap parameter is no longer used in the core xhtml template
function tep_draw_textarea_field($name, $wrap, $width, $height, $text = '', $parameters = '', $reinsert_value = true) {
global $HTTP_GET_VARS, $HTTP_POST_VARS;
$field = '<textarea name="' . tep_output_string($name) . '" cols="' . tep_output_string($width) . '" rows="' . tep_output_string($height) . '"';
if (tep_not_null($parameters)) $field .= ' ' . $parameters;
$field .= '>';
if ( ($reinsert_value == true) && ( (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name])) || (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name])) ) ) {
if (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name])) {
$field .= tep_output_string_protected(stripslashes($HTTP_GET_VARS[$name]));
} elseif (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name])) {
$field .= tep_output_string_protected(stripslashes($HTTP_POST_VARS[$name]));
}
} elseif (tep_not_null($text)) {
$field .= tep_output_string_protected($text);
}
$field .= '</textarea>';
return $field;
}
////
// Output a form hidden field
function tep_draw_hidden_field($name, $value = '', $parameters = '') {
global $HTTP_GET_VARS, $HTTP_POST_VARS;
$field = '<input type="hidden" name="' . tep_output_string($name) . '"';
if (tep_not_null($value)) {
$field .= ' value="' . tep_output_string($value) . '"';
} elseif ( (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name])) || (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name])) ) {
if ( (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name])) ) {
$field .= ' value="' . tep_output_string(stripslashes($HTTP_GET_VARS[$name])) . '"';
} elseif ( (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name])) ) {
$field .= ' value="' . tep_output_string(stripslashes($HTTP_POST_VARS[$name])) . '"';
}
}
if (tep_not_null($parameters)) $field .= ' ' . $parameters;
$field .= ' />';
return $field;
}
////
// Hide form elements
function tep_hide_session_id() {
global $session_started, $SID;
if (($session_started == true) && tep_not_null($SID)) {
return tep_draw_hidden_field(tep_session_name(), tep_session_id());
}
}
////
// Output a form pull down menu
function tep_draw_pull_down_menu($name, $values, $default = '', $parameters = '', $required = false) {
global $HTTP_GET_VARS, $HTTP_POST_VARS;
$field = '<select name="' . tep_output_string($name) . '"';
if (tep_not_null($parameters)) $field .= ' ' . $parameters;
$field .= '>';
if (empty($default) && ( (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name])) || (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name])) ) ) {
if (isset($HTTP_GET_VARS[$name]) && is_string($HTTP_GET_VARS[$name])) {
$default = stripslashes($HTTP_GET_VARS[$name]);
} elseif (isset($HTTP_POST_VARS[$name]) && is_string($HTTP_POST_VARS[$name])) {
$default = stripslashes($HTTP_POST_VARS[$name]);
}
}
for ($i=0, $n=sizeof($values); $i<$n; $i++) {
$field .= '<option value="' . tep_output_string($values[$i]['id']) . '"';
if ($default == $values[$i]['id']) {
$field .= ' selected="selected"';
}
$field .= '>' . tep_output_string($values[$i]['text'], array('"' => '"', '\'' => ''', '<' => '<', '>' => '>')) . '</option>';
}
$field .= '</select>';
if ($required == true) $field .= TEXT_FIELD_REQUIRED;
return $field;
}
////
// Creates a pull-down list of countries
function tep_get_country_list($name, $selected = '', $parameters = '') {
$countries_array = array(array('id' => '', 'text' => PULL_DOWN_DEFAULT));
$countries = tep_get_countries();
for ($i=0, $n=sizeof($countries); $i<$n; $i++) {
$countries_array[] = array('id' => $countries[$i]['countries_id'], 'text' => $countries[$i]['countries_name']);
}
return tep_draw_pull_down_menu($name, $countries_array, $selected, $parameters);
}
////
// Output a jQuery UI Button
function tep_draw_button($title = null, $icon = null, $link = null, $priority = null, $params = null) {
static $button_counter = 1;
$types = array('submit', 'button', 'reset');
if ( !isset($params['type']) ) {
$params['type'] = 'submit';
}
if ( !in_array($params['type'], $types) ) {
$params['type'] = 'submit';
}
if ( ($params['type'] == 'submit') && isset($link) ) {
$params['type'] = 'button';
}
if (!isset($priority)) {
$priority = 'secondary';
}
$button ='';
$button .= '<span class="tdbLink">';
if ( ($params['type'] == 'button') && isset($link) ) {
$button .= '<a id="tdb' . $button_counter . '" href="' . $link . '"';
if ( isset($params['newwindow']) ) {
$button .= ' target="_blank"';
}
} else {
$button .= '<button id="tdb' . $button_counter . '" type="' . tep_output_string($params['type']) . '"';
}
if ( isset($params['params']) ) {
$button .= ' ' . $params['params'];
}
$button .= '>'. $title;
if ( ($params['type'] == 'button') && isset($link) ) {
$button .= '</a>';
} else {
$button .= '</button>';
}
$button .= '</span><script type="text/javascript">$("#tdb' . $button_counter . '").button(';
$args = array();
if ( isset($icon) ) {
if ( !isset($params['iconpos']) ) {
$params['iconpos'] = 'left';
}
if ( $params['iconpos'] == 'left' ) {
$args[] = 'icons:{primary:"ui-icon-' . $icon . '"}';
} else {
$args[] = 'icons:{secondary:"ui-icon-' . $icon . '"}';
}
}
if (empty($title)) {
$args[] = 'text:false';
}
if (!empty($args)) {
$button .= '{' . implode(',', $args) . '}';
}
$button .= ').addClass("ui-priority-' . $priority . '").parent().removeClass("tdbLink");</script>';
$button_counter++;
return $button;
}
?>

I've never liked the image-stretch "fix" contributions. I've always preferred using a thumbnail generator, due to the varying image sizes within different pages on the catalog side.
Try this contribution, after restoring your files to a version previous to the two add-ons you've installed. Instead of fitting an image to a specific size, a package like this will create resampled and appropriately sized copies of the original image, based on the dimensions required by the tep_image parameters.
Another benefit of a method like this that's often overlooked is that also helps to save on bandwidth and reduce page load times. If you upload a 2800px X 1400px image for a product, that file is most likely going to be a multiple MB image. Each time that image is requested on the catalog side, the full file must be downloaded to the browser before any sizing is done, based on the width and height attributes of the IMG tag. The advantage of using thumbnails is that each thumbnail is resampled for its size. Thus, if your product listing only requires a 200px X 100px image, a 200px X 100px image is crafted from the 2800px X 1400px image you uploaded. Depending on your settings, your images could be in the low-KB range.

Related

I have some problem with send and write array in database (Codeingniter 3)

I have a form that sends customer data to the database, I added a choice of another category of customers through the input, and instead of sending the data in text, a number is sent.
db
In View
<?php echo render_select('sellers',get_sellers(),array('articleid','subject'),''); ?>
echo render_select helper:
function render_select($name, $options, $option_attrs = [], $label = '', $selected = '', $select_attrs = [], $form_group_attr = [], $form_group_class = '', $select_class = '', $include_blank = true)
{
$callback_translate = '';
if (isset($options['callback_translate'])) {
$callback_translate = $options['callback_translate'];
unset($options['callback_translate']);
}
$select = '';
$_form_group_attr = '';
$_select_attrs = '';
if (!isset($select_attrs['data-width'])) {
$select_attrs['data-width'] = '100%';
}
if (!isset($select_attrs['data-none-selected-text'])) {
$select_attrs['data-none-selected-text'] = _l('dropdown_non_selected_tex');
}
foreach ($select_attrs as $key => $val) {
// tooltips
if ($key == 'title') {
$val = _l($val);
}
$_select_attrs .= $key . '=' . '"' . $val . '" ';
}
$_select_attrs = rtrim($_select_attrs);
$form_group_attr['app-field-wrapper'] = $name;
foreach ($form_group_attr as $key => $val) {
// tooltips
if ($key == 'title') {
$val = _l($val);
}
$_form_group_attr .= $key . '=' . '"' . $val . '" ';
}
$_form_group_attr = rtrim($_form_group_attr);
if (!empty($select_class)) {
$select_class = ' ' . $select_class;
}
if (!empty($form_group_class)) {
$form_group_class = ' ' . $form_group_class;
}
$select .= '<div class="select-placeholder form-group' . $form_group_class . '" ' . $_form_group_attr . '>';
if ($label != '') {
$select .= '<label for="' . $name . '" class="control-label">' . _l($label, '', false) . '</label>';
}
$select .= '<select id="' . $name . '" name="' . $name . '" class="selectpicker' . $select_class . '" ' . $_select_attrs . ' data-live-search="true">';
if ($include_blank == true) {
$select .= '<option value=""></option>';
}
foreach ($options as $option) {
$val = '';
$_selected = '';
$key = '';
if (isset($option[$option_attrs[0]]) && !empty($option[$option_attrs[0]])) {
$key = $option[$option_attrs[0]];
}
if (!is_array($option_attrs[1])) {
$val = $option[$option_attrs[1]];
} else {
foreach ($option_attrs[1] as $_val) {
$val .= $option[$_val] . ' ';
}
}
$val = trim($val);
if ($callback_translate != '') {
if (function_exists($callback_translate) && is_callable($callback_translate)) {
$val = call_user_func($callback_translate, $key);
}
}
$data_sub_text = '';
if (!is_array($selected)) {
if ($selected != '') {
if ($selected == $key) {
$_selected = ' selected';
}
}
} else {
foreach ($selected as $id) {
if ($key == $id) {
$_selected = ' selected';
}
}
}
if (isset($option_attrs[2])) {
if (strpos($option_attrs[2], ',') !== false) {
$sub_text = '';
$_temp = explode(',', $option_attrs[2]);
foreach ($_temp as $t) {
if (isset($option[$t])) {
$sub_text .= $option[$t] . ' ';
}
}
} else {
if (isset($option[$option_attrs[2]])) {
$sub_text = $option[$option_attrs[2]];
} else {
$sub_text = $option_attrs[2];
}
}
$data_sub_text = ' data-subtext=' . '"' . $sub_text . '"';
}
$data_content = '';
if (isset($option['option_attributes'])) {
foreach ($option['option_attributes'] as $_opt_attr_key => $_opt_attr_val) {
$data_content .= $_opt_attr_key . '=' . '"' . $_opt_attr_val . '"';
}
if ($data_content != '') {
$data_content = ' ' . $data_content;
}
}
$select .= '<option value="' . $key . '"' . $_selected . $data_content . $data_sub_text . '>' . $val . '</option>';
}
$select .= '</select>';
$select .= '</div>';
return $select;
}
get sellers arrays in db functions
function get_sellers()
{
$CI = & get_instance();
return $CI->db->get(db_prefix() . 'sellers')->result_array();
}
I have created a column "sellers" in my table but it sends numbers and not text.
I need it so that when the form is saved it will submit the title and display it in the selection.
Thanks you
View form:
click

How can I have this custom shortcode display within the page content (Divi Builder)?

I am using the Divi Theme.
The shortcode is working, however it is displaying directly under the header rather than where I place the shortcode within the Divi Builder.
I read more about WP shortcodes and it looked like we should be using return rather than echo, but when I change it to return it does not display at all on the page.
Thanks!
function breadcrumb() {
$delimiter = '»'; // delimiter between crumbs
$home = 'Home'; // text for the 'Home' link
$showCurrent = 1; // 1 - show current post/page title in breadcrumbs, 0 - don't show
$before = '<span class="current">'; // tag before the current crumb
$after = '</span>'; // tag after the current crumb
global $post;
$homeLink = get_bloginfo('url');
echo '<div id="crumbs">' . $home . ' ' . $delimiter . ' ';
if (is_single() && !is_attachment()) {
if (get_post_type() != 'post') {
$post_type = get_post_type_object(get_post_type());
$slug = $post_type->rewrite;
return '' . $post_type->labels->singular_name . '';
if ($showCurrent == 1) {
return ' ' . $delimiter . ' ' . $before . get_the_title() . $after;
}
} else {
$cat = get_the_category();
$cat = $cat[0];
$cats = get_category_parents($cat, true, ' ' . $delimiter . ' ');
if ($showCurrent == 0) {
$cats = preg_replace("#^(.+)\s$delimiter\s$#", "$1", $cats);
}
echo $cats;
if ($showCurrent == 1) {
echo $before . get_the_title() . $after;
}
}
} elseif (!is_single() && !is_page() && get_post_type() != 'post' && !is_404()) {
$post_type = get_post_type_object(get_post_type());
return $before . $post_type->labels->singular_name . $after;
} elseif (is_attachment()) {
$parent = get_post($post->post_parent);
$cat = get_the_category($parent->ID);
$cat = $cat[0];
return get_category_parents($cat, true, ' ' . $delimiter . ' ');
echo '' . $parent->post_title . '';
if ($showCurrent == 1) {
echo ' ' . $delimiter . ' ' . $before . get_the_title() . $after;
}
} elseif (is_page() && !$post->post_parent) {
if ($showCurrent == 1) {
return $before . get_the_title() . $after;
}
} elseif (is_page() && $post->post_parent) {
$parent_id = $post->post_parent;
$breadcrumbs = array();
while ($parent_id) {
$page = get_page($parent_id);
$breadcrumbs[] = '' . get_the_title($page->ID) . '';
$parent_id = $page->post_parent;
}
$breadcrumbs = array_reverse($breadcrumbs);
for ($i = 0; $i < count($breadcrumbs); $i++) {
return $breadcrumbs[$i];
if ($i != count($breadcrumbs)-1) {
return ' ' . $delimiter . ' ';
}
}
if ($showCurrent == 1) {
return ' ' . $delimiter . ' ' . $before . get_the_title() . $after;
}
}
return '</div>';
}
function breadcrumb() {
$delimiter = '»'; // delimiter between crumbs
$home = 'Home'; // text for the 'Home' link
$showCurrent = 1; // 1 - show current post/page title in breadcrumbs, 0 - don't show
$before = '<span class="current">'; // tag before the current crumb
$after = '</span>'; // tag after the current crumb
global $post;
$homeLink = get_bloginfo('url');
$bredcrumb = '<div id="crumbs">' . $home . ' ' . $delimiter . ' ';
if (is_single() && !is_attachment()) {
if (get_post_type() != 'post') {
$post_type = get_post_type_object(get_post_type());
$slug = $post_type->rewrite;
$bredcrumb .='' . $post_type->labels->singular_name . '';
if ($showCurrent == 1) {
$bredcrumb .=' ' . $delimiter . ' ' . $before . get_the_title() . $after;
}
} else {
$cat = get_the_category();
$cat = $cat[0];
$cats = get_category_parents($cat, true, ' ' . $delimiter . ' ');
if ($showCurrent == 0) {
$cats = preg_replace("#^(.+)\s$delimiter\s$#", "$1", $cats);
}
$bredcrumb .= $cats;
if ($showCurrent == 1) {
$bredcrumb .= $before . get_the_title() . $after;
}
}
} elseif (!is_single() && !is_page() && get_post_type() != 'post' && !is_404()) {
$post_type = get_post_type_object(get_post_type());
$bredcrumb .= $before . $post_type->labels->singular_name . $after;
} elseif (is_attachment()) {
$parent = get_post($post->post_parent);
$cat = get_the_category($parent->ID);
$cat = $cat[0];
$bredcrumb .= get_category_parents($cat, true, ' ' . $delimiter . ' ');
$bredcrumb .= '' . $parent->post_title . '';
if ($showCurrent == 1) {
$bredcrumb .= ' ' . $delimiter . ' ' . $before . get_the_title() . $after;
}
} elseif (is_page() && !$post->post_parent) {
if ($showCurrent == 1) {
$bredcrumb .= $before . get_the_title() . $after;
}
} elseif (is_page() && $post->post_parent) {
$parent_id = $post->post_parent;
$breadcrumbs = array();
while ($parent_id) {
$page = get_page($parent_id);
$breadcrumbs[] = '' . get_the_title($page->ID) . '';
$parent_id = $page->post_parent;
}
$breadcrumbs = array_reverse($breadcrumbs);
for ($i = 0; $i < count($breadcrumbs); $i++) {
$bredcrumb .= $breadcrumbs[$i];
if ($i != count($breadcrumbs)-1) {
$bredcrumb .= ' ' . $delimiter . ' ';
}
}
if ($showCurrent == 1) {
$bredcrumb .= ' ' . $delimiter . ' ' . $before . get_the_title() . $after;
}
}
$bredcrumb .= '</div>';
echo $bredcrumb;
return $bredcrumb;

Need Help Modifying a WP Page/Post Slider Plugin to go to Unique Page at End

I'm using the Theia Post Slider and I was hoping someone could look at this part of the plugin's code to tell me which part I can modify to get it to go to a unique url at the end.
I tried entering it in place of the $url in this part:
$button = '' . $html . '';
But it didn't work. It looks like it should.
I'd like to just remove the part about checking if there's another post and just have it go straight to the URL but I'm not sure how to do it (beyond my php skill set).
Here's the rest of that section of code the part I modified was near the bottom:
/*
* Get a button for a navigation bar.
* #param direction boolean False = prev; True = next;
*/
public static function get_navigation_barButton( $options, $direction ) {
global $page, $pages;
$directionName = $direction ? 'next' : 'prev';
$url = TpsMisc::get_post_page_url( $options['currentSlide'] + ( $direction ? 1 : - 1 ) );
$leftText = null;
$rightText = null;
// Check if there isn't another page but there is another post.
$urlIsAnotherPost = ! $url && $options[ $directionName . 'PostUrl' ];
if ( $urlIsAnotherPost ) {
$url = $options[ $directionName . 'PostUrl' ];
}
// Check what text we should display on the buttons.
if ( TpsOptions::get( 'post_navigation' ) && ( ( $direction == false && $page == 1 ) || ( $direction == true && $page == count( $pages ) ) ) ) {
$buttonText = TpsOptions::get( $directionName . '_text_post' );
} else {
$buttonText = TpsOptions::get( $directionName . '_text' );
}
switch ( TpsOptions::get( 'theme_type' ) ) {
case 'font':
$text = $directionName == 'next' ? TpsOptions::get_font_icon( 'right' ) : TpsOptions::get_font_icon( 'left' );
$width = 0;
if ( $directionName == 'next' ) {
$leftText = $buttonText;
} else {
$rightText = $buttonText;
}
break;
case 'classic':
$text = $buttonText;
$leftText = '';
$rightText = '';
if ( $urlIsAnotherPost ) {
$width = TpsOptions::get( 'button_width_post' );
} else {
$width = TpsOptions::get( 'button_width' );
}
break;
default:
return '';
}
$style = $width == 0 ? '' : 'style="width: ' . $width . 'px"';
$htmlPart1 = '<span class="_1">' . $leftText . '</span><span class="_2" ' . $style . '>';
$htmlPart2 = '</span><span class="_3">' . $rightText . '</span>';
// HTML
$html = $htmlPart1 . $text . $htmlPart2;
$class = $urlIsAnotherPost ? ' _another_post' : '';
if ( $url ) {
$button = '' . $html . '';
} else {
$button = '<span class="_button _' . $directionName . $class . ' _disabled">' . $html . '</span>';
}
return $button;
}
In case someone wants to do this it turned out to be in the tps.js file line 717. Below where it says URL GOES HERE:
// Set link.
if (
(direction == false && me.options.prevPost && me.currentSlide == 0) ||
(direction == true && me.options.nextPost && me.currentSlide == me.numberOfSlides - 1)
) {
buttonEl.addClass('_another_post');
href = 'URL GOES HERE';
} else {
buttonEl.removeClass('_another_post');
if (me.needToRefreshPage()) {
var slide = me.slides[me.currentSlide + (direction ? 1 : -1)];
if (slide) {
href = slide.permalink;
}
}
else {
href = '#';
}
}

Changing to a multiple column situation in php

Recently we've been creating a website for our business using a purchased WP theme (Jupiter) that my boss, the owner, has had a few very particular modifications he's wanted (some for reasons I don't understand) and given I have working knowledge of HTML and CSS, and very very basic PHP knowledge, I have attempted and been able to make all his customizations except one:
The theme is designed to be responsive, and as such, the custom portfolio gallery style (which appears like an image gallery on computers: http://14d.mercysou.server312.com/photos) will progressively shrink on different devices so that by the time you are down to a smartphone, only 1 column of images will show up and you can scroll down. My supervisor would like it to be customized so that regardless of screen size, even on phones, there is at minimum 2 columns of images across the screen at all times. The PHP for this portfolio gallery (called "masonry") is as follows:
<?php
function mk_portfolio_masonry_loop(&$r, $atts)
{
global $post;
extract($atts);
global $mk_options;
$output = '';
$terms = get_the_terms(get_the_id(), 'portfolio_category');
$terms_slug = array();
$terms_name = array();
if (is_array($terms)) {
foreach ($terms as $term) {
$terms_slug[] = $term->slug;
$terms_name[] = '<span>' . $term->name . '</span>';
}
}
$post_type = get_post_meta($post->ID, '_single_post_type', true);
$post_type = !empty($post_type) ? $post_type : 'image';
$link_to = get_post_meta(get_the_ID(), '_portfolio_permalink', true);
$hover_overlay_value = get_post_meta($post->ID, '_hover_skin', true);
$hover_overlay = !empty($hover_overlay_value) ? (' style="background-color:' . $hover_overlay_value . '"') : '';
$column = get_post_meta(get_the_ID(), '_masonry_img_size', true);
$column = !(empty($column)) ? $column : 'x_x';
switch ($column) {
case 'x_x':
$width = 300;
$height = 300;
break;
case 'two_x_x': //
$width = 600;
$height = 300;
break;
case 'three_x_x':
$width = 900;
$height = 300;
break;
case 'four_x_x':
$width = 1200;
$height = 300;
break;
case 'x_two_x':
$width = 300;
$height = 600;
break;
case 'two_x_two_x':
$width = 600;
$height = 600;
break;
case 'three_x_two_x':
$width = 900;
$height = 600;
break;
case 'four_x_two_x':
$width = 1200;
$height = 600;
break;
default:
$width = 300;
$height = 300;
break;
}
$lightbox_full_size = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full', true);
$permalink = '';
if (!empty($link_to)) {
$link_array = explode('||', $link_to);
switch ($link_array[0]) {
case 'page':
$permalink = get_page_link($link_array[1]);
break;
case 'cat':
$permalink = get_category_link($link_array[1]);
break;
case 'portfolio':
$permalink = get_permalink($link_array[1]);
break;
case 'post':
$permalink = get_permalink($link_array[1]);
break;
case 'manually':
$permalink = $link_array[1];
break;
}
}
if ($ajax == 'true' || empty($permalink)) {
$permalink = get_permalink();
}
$output .= '<article id="' . get_the_ID() . '" class="mk-portfolio-item mk-portfolio-masonry-item masonry-'.$item_id.' mk-isotop-item ' . $hover_scenarios . '-hover size_' . $column . ' portfolio-' . $post_type . ' ' . implode(' ', $terms_slug) . '">';
$image_src_array = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full', true);
$image_src = bfi_thumb($image_src_array[0], array(
'width' => $width * $image_quality,
'height' => $height * $image_quality
));
$item_bg_color_value = get_post_meta($post->ID, '_hover_skin', true);
$item_bg_color = !empty($item_bg_color_value) ? (' background-color:' . $item_bg_color_value . '!important') : '';
$output .= '<div style="margin:0 ' . ($grid_spacing / 2) . 'px ' . $grid_spacing . 'px;" class="item-holder">';
//$output .= ($hover_scenarios == 'fadebox' || $hover_scenarios == 'none') ? '<a class="project-load" data-post-id="' . get_the_ID() . '" href="' . $permalink . '">' : '';
$output .= '<div class="featured-image">';
$output .= '<img alt="' . get_the_title() . '" class="item-featured-image" title="' . get_the_title() . '" src="' . mk_thumbnail_image_gen($image_src, $width, $height) . '" itemprop="image" />';
if ($hover_scenarios == 'fadebox') {
$output .= '<div class="hover-overlay gradient"' . $hover_overlay . '></div>';
} else {
if ($hover_scenarios == 'zoomout') {
$output .= '<div class="image-hover-overlay" style="' . $item_bg_color . '"></div>';
} else {
$output .= '<div class="image-hover-overlay"></div>';
}
}
if ($hover_scenarios == 'fadebox') {
$output .= '<div class="grid-hover-icons">';
if ($post_type == 'image' || $post_type == '') {
$output .= '<a rel="portfolio-grid" title="' . get_the_title() . '" data-fancybox-group="portfolio-masonry-item" class="zoom-badge mk-lightbox" href="' . $image_src_array[0] . '"><i class="mk-jupiter-icon-plus-circle"></i></a>';
} else if ($post_type == 'video') {
$video_id = get_post_meta($post->ID, '_single_video_id', true);
$video_site = get_post_meta($post->ID, '_single_video_site', true);
$video_url = '';
if ($video_site == 'vimeo') {
$video_url = 'http' . ((is_ssl()) ? 's' : '') . '://vimeo.com/' . $video_id . '?autoplay=0';
} elseif ($video_site == 'youtube') {
$video_url = 'http' . ((is_ssl()) ? 's' : '') . '://www.youtube.com/watch?v=' . $video_id . '?autoplay=0';
} elseif ($video_site == 'dailymotion') {
$video_url = 'http' . ((is_ssl()) ? 's' : '') . '://www.dailymotion.com/video/' . $video_id . '?logo=0';
}
$output .= '<a title="' . get_the_title() . '" class="video-badge mk-lightbox" data-fancybox-group="portfolio-masonry-item" href="' . $video_url . '"><i class="mk-jupiter-icon-plus-circle"></i></a>';
}
$output .= '</div>';
}
if ($hover_scenarios == 'light-zoomin' ) {
$output .= '<div class="grid-hover-icons">';
if ($post_type == 'image' || $post_type == '') {
$output .= '<a rel="portfolio-grid" title="' . get_the_title() . '" data-fancybox-group="portfolio-masonry-item" class="zoom-badge mk-lightbox" href="' . $image_src_array[0] . '"><i class="mk-jupiter-icon-plus-circle"></i></a>';
} else if ($post_type == 'video') {
$video_id = get_post_meta($post->ID, '_single_video_id', true);
$video_site = get_post_meta($post->ID, '_single_video_site', true);
$video_url = '';
if ($video_site == 'vimeo') {
$video_url = 'http' . ((is_ssl()) ? 's' : '') . '://vimeo.com/' . $video_id . '?autoplay=0';
} elseif ($video_site == 'youtube') {
$video_url = 'http' . ((is_ssl()) ? 's' : '') . '://www.youtube.com/watch?v=' . $video_id . '?autoplay=0';
} elseif ($video_site == 'dailymotion') {
$video_url = 'http' . ((is_ssl()) ? 's' : '') . '://www.dailymotion.com/video/' . $video_id . '?logo=0';
}
$output .= '<a title="' . get_the_title() . '" class="video-badge mk-lightbox" data-fancybox-group="portfolio-masonry-item" href="' . $video_url . '"><i class="mk-jupiter-icon-plus-circle"></i></a>';
}
$output .= '</div>';
}
if ($hover_scenarios != 'fadebox' && $hover_scenarios != 'light-zoomin' && $hover_scenarios != 'none') {
$output .= '<div class="grid-hover-icons">';
if ($post_type == 'image' || $post_type == '') {
$output .= '<a data-fancybox-group="portfolio-grid" title="' . get_the_title() . '" class="zoom-badge mk-lightbox" href="' . $lightbox_full_size[0] . '"><i class="mk-jupiter-icon-plus-circle"></i></a>';
} else if ($post_type == 'video') {
$video_id = get_post_meta($post->ID, '_single_video_id', true);
$video_site = get_post_meta($post->ID, '_single_video_site', true);
$video_url = '';
if ($video_site == 'vimeo') {
$video_url = 'http' . ((is_ssl()) ? 's' : '') . '://vimeo.com/' . $video_id . '?autoplay=0';
} elseif ($video_site == 'youtube') {
$video_url = 'http' . ((is_ssl()) ? 's' : '') . '://www.youtube.com/watch?v=' . $video_id . '?autoplay=0';
} elseif ($video_site == 'dailymotion') {
$video_url = 'http' . ((is_ssl()) ? 's' : '') . '://www.dailymotion.com/video/' . $video_id . '?logo=0';
}
$output .= '<a title="' . get_the_title() . '" class="video-badge mk-lightbox" href="' . $video_url . '"><i class="mk-jupiter-icon-plus-circle"></i></a>';
}
$output .= '</div>';
}
if ($hover_scenarios != 'none') {
$output .= ($hover_scenarios == 'slidebox') ? '<div class="portfolio-meta"' . $hover_overlay . '>' : '<div class="portfolio-meta">';
$output .= '<h3 class="the-title">' . get_the_title() . '</h3><div class="clearboth"></div>';
if ($meta_type == 'category') {
$output .= '<div class="portfolio-categories">' . implode(', ', $terms_name) . ' </div>';
} else {
$output .= '<time class="portfolio-date" datetime="' . get_the_date() . '">' . get_the_date() . '</time>';
}
$output .= '</div><!-- Portfolio meta -->';
}
$output .= '</div><!-- Featured Image -->';
//$output .= ($hover_scenarios == 'fadebox' || $hover_scenarios == 'none') ? '</a><!-- project load -->' : '';
$output .= '</div>';
$output .= '</article>' . "\n\n\n";
return $output;}
I'm aware that what I need to modify in order to achieve my desired 2 column style is on and around line 30, particularly this part:
$column = get_post_meta(get_the_ID(), '_masonry_img_size', true);
$column = !(empty($column)) ? $column : 'x_x';
switch ($column) {
case 'x_x':
$width = 300;
$height = 300;
break;
case 'two_x_x': //
$width = 600;
$height = 300;
break;
case 'three_x_x':
$width = 900;
$height = 300;
break;
case 'four_x_x':
$width = 1200;
$height = 300;
break;
case 'x_two_x':
$width = 300;
$height = 600;
break;
case 'two_x_two_x':
$width = 600;
$height = 600;
break;
case 'three_x_two_x':
$width = 900;
$height = 600;
break;
case 'four_x_two_x':
$width = 1200;
$height = 600;
break;
default:
$width = 300;
$height = 300;
break;
}
I have read several tutorials and attempted my best to create a 2 column function and use that in the switch instead but I fear that my knowledge of PHP is just not good enough to properly implement this. Any thoughts, suggestions, or help would be greatly appreciated as I am no professional, we don't have the budget to hire one, and yet the responsibility has fallen on me as I'm the only somewhat web literate guy in the office.
seeing as it is responsive it stands to reason that its the css that forces the 2 columns. I can't be certain because i cant see the code but i would do this with css media queries, making the items in the columns 100% width when reaching a specific screen width. if this is the case try and find the code that does that and make the width 50%.
I cannot guarantee this will work without seeing the whole code but its a start for you. the php doesn't know the screen width.

using an image for a button on php

I have a php script which creates its own button, as I am using an open source framework. What I want is to use an image to create a button instead of a the link the is created. Here is the line for which I need the button:
<td class="main button_marg"><?php echo tep_draw_button(IMAGE_BUTTON_REVIEWS . (($reviews['count'] > 0) ? ' (' . $reviews['count'] . ')' : ''), 'comment', tep_href_link(FILENAME_PRODUCT_REVIEWS, tep_get_all_get_params())); ?></td>
That is the script I am using to create the review button, but I would like to insert an image into it. Any ideas would be most appreciative.
This is the code for tep_draw_button() function:
function tep_draw_button($title = null, $icon = null, $link = null, $priority = null, $params = null) {
static $button_counter = 1;
$types = array('submit', 'button', 'reset');
if ( !isset($params['type']) ) {
$params['type'] = 'submit';
}
if ( !in_array($params['type'], $types) ) {
$params['type'] = 'submit';
}
if ( ($params['type'] == 'submit') && isset($link) ) {
$params['type'] = 'button';
}
if (!isset($priority)) {
$priority = 'secondary';
}
$button = '<span class="tdbLink">';
if ( ($params['type'] == 'button') && isset($link) ) {
$button .= '<a id="tdb' . $button_counter . '" href="' . $link . '"';
if ( isset($params['newwindow']) ) {
$button .= ' target="_blank"';
}
} else {
$button .= '<button id="tdb' . $button_counter . '" type="' . tep_output_string($params['type']) . '"';
}
if ( isset($params['params']) ) {
$button .= ' ' . $params['params'];
}
$button .= '>' . $title;
if ( ($params['type'] == 'button') && isset($link) ) {
$button .= '</a>';
} else {
$button .= '</button>';
}
$button .= '</span><script type="text/javascript">$("#tdb' . $button_counter . '").button(';
$args = array();
if ( isset($icon) ) {
if ( !isset($params['iconpos']) ) {
$params['iconpos'] = 'left';
}
if ( $params['iconpos'] == 'left' ) {
$args[] = 'icons:{primary:"ui-icon-' . $icon . '"}';
} else {
$args[] = 'icons:{secondary:"ui-icon-' . $icon . '"}';
}
}
if (empty($title)) {
$args[] = 'text:false';
}
if (!empty($args)) {
$button .= '{' . implode(',', $args) . '}';
}
$button .= ').addClass("ui-priority-' . $priority . '").parent().removeClass("tdbLink");</script>';
$button_counter++;
return $button;
}
?>
You can probably override the style by using some css:
#your_button_id{ background: url(); height: x; width: x; etc... }
.your_button_class{ background: url(); height: x; width: x; etc... }
Try this:
To call the button, use the function with the parameters as they are below:
$image['src'] = 'http://yoururl.com/image.jpg'; // Image Source
$image['height'] = 600; // Image Height
$image['width'] = 300; // Image Width
tep_draw_button(IMAGE_BUTTON_REVIEWS . (($reviews['count'] > 0) ? ' (' . $reviews['count'] . ')' : ''), 'comment', tep_href_link(FILENAME_PRODUCT_REVIEWS, tep_get_all_get_params()), null, null, $image);
Then modify the tep_draw_button function like so. If you have an image source in the function parameter, the image will be placed in as a link rather than as a button.
<?
function tep_draw_button($title = null, $icon = null, $link = null, $priority = null, $params = null, $image = null) {
static $button_counter = 1;
if($image != null){
$button = '<span class="tdbLink">';
$button .= '<a id="tdb' . $button_counter . '" href="' . $link . '"';
$button .= '><img src="'. $image['src'] .'"';
if(is_numeric($image['height'])) $button .= ' height="'.$image['height'].'"';
if(is_numeric($image['width'])) $button .= ' width="'.$image['width'].'"';
$button .= 'alt="'.$title.'" /></a></span>';
}else{
$types = array('submit', 'button', 'reset');
if ( !isset($params['type']) ) {
$params['type'] = 'submit';
}
if ( !in_array($params['type'], $types) ) {
$params['type'] = 'submit';
}
if ( ($params['type'] == 'submit') && isset($link) ) {
$params['type'] = 'button';
}
if (!isset($priority)) {
$priority = 'secondary';
}
$button = '<span class="tdbLink">';
if ( ($params['type'] == 'button') && isset($link) ) {
$button .= '<a id="tdb' . $button_counter . '" href="' . $link . '"';
if ( isset($params['newwindow']) ) {
$button .= ' target="_blank"';
}
} else {
$button .= '<button id="tdb' . $button_counter . '" type="' . tep_output_string($params['type']) . '"';
}
if ( isset($params['params']) ) {
$button .= ' ' . $params['params'];
}
$button .= '>' . $title;
if ( ($params['type'] == 'button') && isset($link) ) {
$button .= '</a>';
} else {
$button .= '</button>';
}
$button .= '</span><script type="text/javascript">$("#tdb' . $button_counter . '").button(';
$args = array();
if ( isset($icon) ) {
if ( !isset($params['iconpos']) ) {
$params['iconpos'] = 'left';
}
if ( $params['iconpos'] == 'left' ) {
$args[] = 'icons:{primary:"ui-icon-' . $icon . '"}';
} else {
$args[] = 'icons:{secondary:"ui-icon-' . $icon . '"}';
}
}
if (empty($title)) {
$args[] = 'text:false';
}
if (!empty($args)) {
$button .= '{' . implode(',', $args) . '}';
}
$button .= ').addClass("ui-priority-' . $priority . '").parent().removeClass("tdbLink");</script>';
$button_counter++;
}
return $button;
}
?>
Let me know if this works, or if you need it tweaked at all. It's hard for me to test since I don't have an oscommerce instance on my machine to test on.

Categories