Wrong media files url on WordPress site - wordpress

I have met a problem on WordPress site:
None images uploaded as media files are showing. I see they have wrong url like this
<a class="thumbLink" href="http:///wp-content/uploads/2014/10/Joseph-Angharad-11.7.2014-271.jpg" rel="prettyPhoto[gallery1]" title=""><i class="icon-search"></i></a>
I've tried to upload new media files and they get similar url and don't displayed.
In the database it seems ok. I don't see such url in it.
Have you met such a problem? Where to look resolving?
As far as I know it happened before removing a plugin (which was inactive).
I get images via the following code:
// instantiate the controller
if (!function_exists("peTheme")) {
$peThemeClassName = apply_filters('pe_theme_controller_classname','PeTheme'.PE_THEME_NAME);
PeGlobal::$controller =& new $peThemeClassName();
function &peTheme() {
return PeGlobal::$controller;
}
peTheme()->boot();
}
<?php $t =& peTheme(); ?>
<section class="thumbImage">
<img src="<?php echo $t->image->resizedImgUrl($content->get_origImage(),350,0); ?>" alt="" class="fullwidth">
<div class="thumbTextWrap">
<div class="thumbText">
<h3 class="sectionTitle"><?php $content->title(); ?></h3>
<?php
$text = get_the_excerpt();
if (strlen($text) > 40)
$text = substr($text, 0, 40) . '...';
echo '<p>' . $text . '</p>';
?>
<?php while ($slide =& $slider->next()): ?>
<?php $img = $slide->img; ?>
<?php
if ( $first ) {
?>
<a class="thumbLink" href="<?php echo $img; ?>" rel="prettyPhoto['<?php $content->slug(); ?>']" title=""><i class="icon-search"></i></a>
<?php
$first = false;
} else {
?>
<?php
}
<?php endwhile; ?>
</div>
</div>
</section>

It quite silly of me but I didn't disable plugins to check.
The problem was in a Parallelize plugin. It has been disabled and from now media files have right url.

This post may be a little outdated, but I had a similar recent issue so in case it proves useful to anyone:
To start, I had previously changed the Wordpress upload directory by adding the following to the end of wp-config.php
define( 'UPLOADS', ''.'files' );
So all my files are saved in domain.com/files/ After upgrading to Wordpress 4.5, all media files had very wrong url, (with something crazy like .../wp-content/uploads/rootuser/public_html/wp-content/uploads...) I tried reinstalling Wordpress, changing the directory again, disabling plugins, then I found a few posts about the Search & Replace working for some, but still no luck.
Then I found this plugin, Upload Url and Path Enabler and used the following settings that suited my situation:
Store Files: files
Full File URL: http://www.domain.com/files
And presto! All media URLs magically updated and all is working again!

Related

Get attached file url from upload WCK Wordpress plugin custom field creator not an image type

How to get the attached file from WCK plugin in Wordpress eventhough it is not an image? like an audio file.
This is the code that I have tried and it works! :)
Below is just an example.
<?php
$wck_custom = get_post_meta( $post->ID, 'audiosamps', true);
foreach($wck_custom as $wck_cstm) {
$audio_file = $wck_cstm['audio_file'];
$src_audio_file = wp_get_attachment_url( $audio_file);
?>
<div class="audio-cont"><audio src="<?php echo $src_audio_file; ?>"></audio></div>
<?php } ?>
With the used of wp_get_attachment_url() function from Wordpress

wordpress advance custom field plugin showing broken image?

I am using wordpress acf plugin to show some custom images with their description and some text. So first I just made the acf plugin fileds like this and assigned the page to the home page with the conditional tags Location-> Rules-> Page->is equal to-> Home
now when I made my content-page.php to show the image code like this
<?php
if( get_field('image') ):
?><img src="<?php the_field('image'); ?>" alt="" /><?php
endif;
?>
I am getting only a broken image. The firebug is showing image source like this
Kindly help me to solve this. I have already wasted one day behind it. So any help and suggestions will be really appreciable. Thanks
Here is the screen shot for my custom fields setup
Here is the firebug html code which is showing the image source
Had this problem too. This is what I came up with that works:
<?php if (get_field('staff_photo')) {
$imgarray = get_field( 'staff_photo' );
?>
<img src="<?php echo $imgarray['url'] ; ?>" alt="" class="staff-photo" />
<?php } ?>
So, what I did was put get_field('field_name') array into a variable, then took a WAG that the key was 'url', which it was. Seems like the ACF people need to update their documentation.
Hah! Discovered another way -- this way you can pick a size:
<?php
if ( get_field('staff_photo') ) {
$imgarray = get_field( 'staff_photo' );
$size = "thumbnail"; // (thumbnail, medium, large, full or custom size)
echo wp_get_attachment_image( $imgarray['id'], $size );
}
?>
For wp_get_attachemnt_image to work, you have to extract the image id, for which the key is, ta-da! 'id'.

Change Read More link WordPress

I want to change the Read More link in WordPress, i have found some tutorials where in the <!-- more --> i can write something else <!-- more Proceed... --> (this did not work).
And in the index.php i should edit <?php the_content('Read More..,'); ?>, but in my index.php there is no Read More text, it looks like this <?php the_content(''); ?>, it is empty and it still shows Read More on posts.
Any other ideas how to change it ?
You can change the
<?php the_content(''); ?>
into whatever you want. So you can make it:
<?php the_content('more Proceed... '); ?>
or whatever you want. "Read more..." is default when you leave it open.
add this block of code in function.php file
// Replaces the excerpt "more" text by a link
function new_excerpt_more($more) {
global $post;
return '<a class="moretag" href="'. get_permalink($post->ID) . '"> Read more... </a>';
}
add_filter('excerpt_more', 'new_excerpt_more');

php logo call in block - Drupal 7

I am building out a site in drupal 7 and running into a ton of problems... very new to drupal here.
I pulled the php call for the logo out of the page.tpl file and put into the header block to be added to all pages. I understand I should probably just leave it in the page.tpl file but thought it made sense to utilize the header block but it is no longer working. can someone explain why this is not working?
here is the code
<div id="logo"><?php if ($logo): ?>
<img src="<?php print $logo; ?>" alt="<?php print t('Home'); ?>" />
<?php endif; ?></div>
It's because the variable $logo is not available in block.tpl.php, it is provided only to page.tpl.php.
You can actually grab the values yourself like this:
$theme_name = 'name_of_theme';
$settings = variable_get('theme_' . $theme_name . '_settings', array());
if (isset($settings['logo_path'])) {
$logo = file_create_url($settings['logo_path']);
}
all what you need, it's additions in template.php this code
function hook_preprocess_region(&$variables) {
$variables['logo'] = theme_get_setting('logo');
$variables['front_page'] = variable_get('site_frontpage', 'node');
}
clear cache
and $logo and $front_page will works good.

Drupal - White Screen Of Death

Just changed themes with drupal and I'm left with white screen of death. Default theme which worked was Zen. This is stored under sites/mysite.com/themes
Theme I changed to I think is one of the themes under themes/
Don't have access to the database. Have FTP access.
Is there any way to change themes or install one that will work?
The easiest way to correct your problem is to find what's wrong.
go to index.php and add the following lines after <?php
ini_set('display_errors',1);
error_reporting(E_ALL|E_STRICT);
Then post the error here.
Don't forget to comment/remove when you're done.
EDIT:
If I understood correctly this was what you did before going WSOD.
You were using Zen theme.
You logged into your site with administrator privileges and went to http://yoursite.com/admin
You went to the theme management and changed your theme to another one (henceforth refered as "theme_b")
When refreshed the page (or went to another page in your site) you got the WSOD.
.
If this is true then follow these steps:
Create a blank theme.
In order to do this, create a folder in your computer named "theme_b".
Inside create the following files:
theme_b.info, template.php, style.css and page.tpl.php
Open theme_b.info and paste this:
name = theme_b
description = bla
version = 1
core = 6.x
engine = phptemplate
stylesheets[all][] = style.css
Save.
Open page.tpl.php and paste this:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<?php print $head ?>
<title><?php print $head_title ?></title>
<?php print $styles ?>
<?php print $scripts ?>
</head>
<body>
<div><?php print theme('links', $primary_links, array('class' => 'links primary-links')) ?></div>
<div><?php print theme('links', $secondary_links, array('class' => 'links secondary-links')) ?></div>
<div id="sidebar-left" class="sidebar"><?php print $left ?></div>
<div>
<?php if ($tabs): print '<div id="tabs-wrapper" class="clear-block">'; endif; ?>
<?php if ($title): print '<h2'. ($tabs ? ' class="with-tabs"' : '') .'>'. $title .'</h2>'; endif; ?>
<?php if ($tabs): print '<ul class="tabs primary">'. $tabs .'</ul></div>'; endif; ?>
<?php if ($tabs2): print '<ul class="tabs secondary">'. $tabs2 .'</ul>'; endif; ?>
<?php if ($show_messages && $messages): print $messages; endif; ?>
<?php print $help; ?>
</div>
<div>
<?php print $content; ?>
</div>
</body>
</html>
Save.
Then upload the folder theme_a to sites/yoursite.com/themes replacing existing theme_a folder.
This should enable you to access admin section of drupal.
You won't necessarily see any errors. For me it was a caching issue which stopped the page from loading the right content.
I cleared the cache by inserting the following on the last line of my index.php file (in Drupal root). This solved the issue for me:
db_query("DELETE FROM {cache};");
Remember to remove the line again afterwards.
More information about caching, look here: https://drupal.org/node/42055
It's most probably a PHP silent death because there's not enough memory allocated to scripts in /etc/php.ini
On shared hosting environments, you MAY be able to override this using a .htaccess file.
You more than likely have a PHP error that isn't being shown because error reporting is turned off by default on your host. The easiest way to remedy this is to add the following code at the top of index.php:
<?php
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
Additionally, you definitely want to locate your php error logs and see if there is any additional information regarding the error there.
Checkout the Drupal help page for this topic: http://drupal.org/node/158043

Resources